Ignore:
Timestamp:
Aug 7, 2017, 12:50:17 PM (7 years ago)
Author:
alain
Message:

Introduce the delayed context switch if current thread has a lock.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/printk.c

    r296 r337  
    217217
    218218//////////////////////////////////////////////////////////////////////////////////////
    219 // This static function is called by printk() and user_printk() to build
     219// This static function is called by printk(), assert() and nolock_printk() to build
    220220// a formated string.
    221221//////////////////////////////////////////////////////////////////////////////////////
     
    375375}  // end kernel_printf()
    376376
    377 /////////////////////////////////
    378 void printk( char * format , ...)
     377//////////////////////////////////
     378void printk( char * format , ... )
    379379{
    380380    va_list       args;
     
    401401}
    402402
    403 ////////////////////////////////////////
    404 void nolock_printk( char * format , ...)
     403/////////////////////////////////////////
     404void nolock_printk( char * format , ... )
    405405{
    406406    va_list       args;
     
    412412}
    413413
    414 ///////////////////////////////////////////
    415 inline void assert( bool_t       condition,
    416                     const char * function_name,
    417                     char       * string )
    418 {
     414////////////////////////////////////
     415void assert( bool_t       condition,
     416             const char * function_name,
     417             char       * format, ... )
     418{
     419    va_list       args;
     420    uint32_t      save_sr;
     421
    419422    if( condition == false )
    420423    {
    421         printk("\n[PANIC] in %s : %s\n" , function_name , string );
     424        // get pointers on TXT0 chdev
     425        xptr_t    txt0_xp  = chdev_dir.txt[0];
     426        cxy_t     txt0_cxy = GET_CXY( txt0_xp );
     427        chdev_t * txt0_ptr = GET_PTR( txt0_xp );
     428
     429        // get extended pointer on remote TXT0 chdev lock
     430        xptr_t  lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
     431
     432        // get TXT0 lock in busy waiting mode
     433        remote_spinlock_lock_busy( lock_xp , &save_sr );
     434
     435        // call nolock_printk to print function_name
     436        nolock_printk("\n[PANIC] in %s : " , function_name );
     437
     438        // call kernel_printf on TXT0, in busy waiting to print format
     439        va_start( args , format );
     440        kernel_printf( 0 , 1 , format , &args );
     441        va_end( args );
     442
     443        // release TXT0 lock
     444        remote_spinlock_unlock_busy( lock_xp , save_sr );
     445
     446        // suicide
    422447        hal_core_sleep();
    423448    }
Note: See TracChangeset for help on using the changeset viewer.