Ignore:
Timestamp:
Feb 20, 2018, 5:32:17 PM (6 years ago)
Author:
alain
Message:

Fix a bad bug in scheduler...

File:
1 edited

Legend:

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

    r433 r435  
    3939extern chdev_directory_t    chdev_dir;   // allocated in kernel_init.c
    4040
    41 #if CONFIG_READ_DEBUG
    42 extern uint32_t enter_chdev_cmd;
    43 extern uint32_t exit_chdev_cmd;
    44 extern uint32_t enter_chdev_server;
    45 extern uint32_t exit_chdev_server;
     41#if (CONFIG_DEBUG_SYS_READ & 1)
     42extern uint32_t enter_chdev_cmd_read;
     43extern uint32_t exit_chdev_cmd_read;
     44extern uint32_t enter_chdev_server_read;
     45extern uint32_t exit_chdev_server_read;
     46#endif
     47
     48#if (CONFIG_DEBUG_SYS_WRITE & 1)
     49extern uint32_t enter_chdev_cmd_write;
     50extern uint32_t exit_chdev_cmd_write;
     51extern uint32_t enter_chdev_server_write;
     52extern uint32_t exit_chdev_server_write;
    4653#endif
    4754
     
    123130    uint32_t   save_sr;       // for critical section
    124131
    125 #if CONFIG_READ_DEBUG
    126 enter_chdev_cmd = hal_time_stamp();
     132#if (CONFIG_DEBUG_SYS_READ & 1)
     133enter_chdev_cmd_read = (uint32_t)hal_get_cycles();
     134#endif
     135
     136#if (CONFIG_DEBUG_SYS_WRITE & 1)
     137enter_chdev_cmd_write = (uint32_t)hal_get_cycles();
    127138#endif
    128139
     
    178189    if( different ) dev_pic_send_ipi( chdev_cxy , lid );
    179190   
     191    // deschedule
     192    assert( thread_can_yield( this ) , __FUNCTION__ , "illegal sched_yield\n" );
     193    sched_yield("blocked on I/O");
     194
     195    // exit critical section
     196    hal_restore_irq( save_sr );
     197
    180198#if CONFIG_DEBUG_CHDEV_REGISTER_COMMAND
    181199cycle = (uint32_t)hal_get_cycles();
     
    185203#endif
    186204
    187     // deschedule
    188     assert( thread_can_yield( this ) , __FUNCTION__ , "illegal sched_yield\n" );
    189     sched_yield("blocked on I/O");
    190 
    191     // exit critical section
    192     hal_restore_irq( save_sr );
    193 
    194 #if CONFIG_DEBUG_CHDEV_REGISTER_COMMAND
    195 cycle = (uint32_t)hal_get_cycles();
    196 if( CONFIG_DEBUG_CHDEV_REGISTER_COMMAND < cycle )
    197 printk("\n[DBG] %s : client_thread %x (%s) resumes / cycle %d\n",
    198 __FUNCTION__, this, thread_type_str(this->type) , cycle );
    199 #endif
    200 
    201 #if CONFIG_READ_DEBUG
    202 exit_chdev_cmd = hal_time_stamp();
     205#if (CONFIG_DEBUG_SYS_READ & 1)
     206exit_chdev_cmd_read = (uint32_t)hal_get_cycles();
     207#endif
     208
     209#if (CONFIG_DEBUG_SYS_WRITE & 1)
     210exit_chdev_cmd_write = (uint32_t)hal_get_cycles();
    203211#endif
    204212
     
    240248            remote_spinlock_unlock( lock_xp );
    241249
    242 chdev_dmsg("\n[DBG] %s : thread %x deschedule /cycle %d\n",
    243 __FUNCTION__ , server , hal_time_stamp() );
    244 
    245250            // deschedule
    246251            sched_yield("I/O queue empty");
    247 
    248 chdev_dmsg("\n[DBG] %s : thread %x resume /cycle %d\n",
    249 __FUNCTION__ , server , hal_time_stamp() );
    250 
    251252        }
    252253        else                            // waiting queue not empty
    253254        {
    254255
    255 #if CONFIG_READ_DEBUG
    256 enter_chdev_server = hal_time_stamp();
    257 #endif
     256#if (CONFIG_DEBUG_SYS_READ & 1)
     257enter_chdev_server_read = (uint32_t)hal_get_cycles();
     258#endif
     259
     260#if (CONFIG_DEBUG_SYS_WRITE & 1)
     261enter_chdev_server_write = (uint32_t)hal_get_cycles();
     262#endif
     263
    258264            // release lock
    259265            remote_spinlock_unlock( lock_xp );
     
    284290#endif
    285291
    286 #if CONFIG_READ_DEBUG
    287 exit_chdev_server = hal_time_stamp();
     292#if (CONFIG_DEBUG_SYS_READ & 1)
     293exit_chdev_server_read = (uint32_t)hal_get_cycles();
     294#endif
     295
     296#if (CONFIG_DEBUG_SYS_WRITE & 1)
     297exit_chdev_server_write = (uint32_t)hal_get_cycles();
    288298#endif
    289299
Note: See TracChangeset for help on using the changeset viewer.