Ignore:
Timestamp:
Jun 29, 2018, 10:44:14 AM (6 years ago)
Author:
alain
Message:

Fix a bug in function sched_handle_signal():
When the deleted user thread is the last executed thread,
the sched->u_last field must be updated to point on another user thread.

File:
1 edited

Legend:

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

    r447 r450  
    163163uint32_t rx_cycle = (uint32_t)hal_get_cycles();
    164164if( (is_rx) && (DEBUG_CHDEV_CMD_RX < rx_cycle) )
    165 printk("\n[DBG] %s : client_thread %x (%s) enter for RX / cycle %d\n",
    166 __FUNCTION__, this, thread_type_str(this->type) , rx_cycle );
     165printk("\n[DBG] %s : client_thread %x (%s) enter for RX / server = %x / cycle %d\n",
     166__FUNCTION__, this, thread_type_str(this->type) , server_ptr, rx_cycle );
    167167#endif
    168168
     
    170170uint32_t tx_cycle = (uint32_t)hal_get_cycles();
    171171if( (is_rx == 0) && (DEBUG_CHDEV_CMD_TX < tx_cycle) )
    172 printk("\n[DBG] %s : client_thread %x (%s) enter for TX / cycle %d\n",
    173 __FUNCTION__, this, thread_type_str(this->type) , tx_cycle );
     172printk("\n[DBG] %s : client_thread %x (%s) enter for TX / server = %x / cycle %d\n",
     173__FUNCTION__, this, thread_type_str(this->type) , server_ptr, tx_cycle );
    174174#endif
    175175
     
    186186    lock_xp = XPTR( chdev_cxy , &chdev_ptr->wait_lock );
    187187
    188     // critical section for the following sequence:
     188    // critical section for the following sequence: 
    189189    // (1) take the lock protecting waiting queue
    190190    // (2) block the client thread
     
    205205    thread_block( XPTR( local_cxy , CURRENT_THREAD ) , THREAD_BLOCKED_IO );
    206206
     207#if (DEBUG_CHDEV_CMD_TX & 1)
     208if( (is_rx == 0) && (DEBUG_CHDEV_CMD_TX < tx_cycle) )
     209printk("\n[DBG] in %s : client thread %x blocked\n", __FUNCTION__, this );
     210#endif
     211
    207212    // unblock server thread if required
    208213    if( hal_remote_lw( blocked_xp ) & THREAD_BLOCKED_IDLE )
    209214    thread_unblock( server_xp , THREAD_BLOCKED_IDLE );
    210215
     216#if (DEBUG_CHDEV_CMD_TX & 1)
     217if( (is_rx == 0) && (DEBUG_CHDEV_CMD_TX < tx_cycle) )
     218{
     219printk("\n[DBG] in %s : server thread %x unblocked\n", __FUNCTION__, server_ptr );
     220chdev_queue_display( chdev_xp );
     221}
     222#endif
     223
    211224    // register client thread in waiting queue
    212225    xlist_add_last( root_xp , list_xp );
    213226
     227#if (DEBUG_CHDEV_CMD_TX & 1)
     228if( (is_rx == 0)  && (DEBUG_CHDEV_CMD_TX < tx_cycle) )
     229{
     230printk("\n[DBG] in %s : thread %x registered write request in chdev\n", __FUNCTION__, this );
     231chdev_queue_display( chdev_xp );
     232}
     233#endif
     234 
    214235    // send IPI to core running the server thread when server != client
    215236    different = (lid != this->core->lid) || (local_cxy != chdev_cxy);
    216     if( different ) dev_pic_send_ipi( chdev_cxy , lid );
     237    if( different )
     238    {
     239        dev_pic_send_ipi( chdev_cxy , lid );
    217240   
     241#if (DEBUG_CHDEV_CMD_TX & 1)
     242if( (is_rx == 0)  && (DEBUG_CHDEV_CMD_TX < tx_cycle) )
     243printk("\n[DBG] in %s : client thread %x sent IPI to server thread %x\n",
     244__FUNCTION__, this, server_ptr );
     245#endif
     246
     247    }
     248 
    218249    // release lock
    219250    remote_spinlock_unlock( lock_xp );
     
    492523
    493524    // get extended pointer on root of requests queue
    494     root_xp = hal_remote_lwd( XPTR( chdev_cxy , &chdev_ptr->wait_root ) );
     525    root_xp = XPTR( chdev_cxy , &chdev_ptr->wait_root );
    495526
    496527    // get chdev name
     
    516547                        pid        = hal_remote_lw ( XPTR( thread_cxy , &process->pid        ) );
    517548
    518             printk("- trdid %X / pid %X\n", trdid, pid );
     549            printk("- thread %X / cluster %X / trdid %X / pid %X\n",
     550            thread_ptr, thread_cxy, trdid, pid );
    519551        }
    520552    }
Note: See TracChangeset for help on using the changeset viewer.