Ignore:
Timestamp:
Oct 1, 2015, 4:20:46 PM (9 years ago)
Author:
alain
Message:

Major release: Change the task model to implement the POSIX threads API.

  • The shell "exec" and "kill" commands can be used to activate/de-activate the applications.
  • The "pause", "resume", and "context" commands can be used to stop, restart, a single thtead or to display the thread context.

This version has been tested on the following multi-threaded applications,
that have been modified to use the POSIX threads:

  • classif
  • convol
  • transpose
  • gameoflife
  • raycast
File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_drivers/bdv_driver.c

    r657 r709  
    3737spin_lock_t  _bdv_lock __attribute__((aligned(64)));
    3838
    39 // global index of the waiting task (only used in descheduling mode)
     39// global index of the waiting thread (only used in descheduling mode)
    4040__attribute__((section(".kdata")))
    41 unsigned int _bdv_gtid;
     41unsigned int _bdv_trdid;
    4242
    4343// BDV peripheral status (only used in descheduling mode)
     
    7575                          unsigned int       count)
    7676{
    77     unsigned int procid  = _get_procid();
    78     unsigned int x       = procid >> (Y_WIDTH + P_WIDTH);
    79     unsigned int y       = (procid >> P_WIDTH) & ((1<<Y_WIDTH) - 1);
    80     unsigned int p       = procid & ((1<<P_WIDTH)-1);
    81 
    82 #if GIET_DEBUG_IOC
     77
     78#if GIET_DEBUG_IOC
     79unsigned int procid  = _get_procid();
     80unsigned int x       = procid >> (Y_WIDTH + P_WIDTH);
     81unsigned int y       = (procid >> P_WIDTH) & ((1<<Y_WIDTH) - 1);
     82unsigned int p       = procid & ((1<<P_WIDTH)-1);
    8383if ( _get_proctime() > GIET_DEBUG_IOC )
    8484_printf("\n[BDV DEBUG] P[%d,%d,%d] enters _bdv_access at cycle %d\n"
     
    9797    unsigned int status;
    9898
    99     // get the lock protecting BDV
     99    // get the BDV lock and register it in task context
     100    static_scheduler_t*  psched = _get_sched();
     101    unsigned int         ltid   = _get_thread_ltid();
    100102    _spin_lock_acquire( &_bdv_lock );
     103    _atomic_or( &psched->context[ltid].slot[CTX_LOCKS_ID] , LOCKS_MASK_BDV );
    101104
    102105    // set device registers
     
    149152
    150153    /////////////////////////////////////////////////////////////////
    151     // in descheduling mode, we deschedule the task
    152     // and use an interrupt to reschedule the task.
     154    // in descheduling mode, we deschedule the thread
     155    // and use an interrupt to reschedule the thread.
    153156    // We need a critical section, because we must reset the RUN bit
    154157        // before to launch the transfer, and we don't want to be
     
    158161    {
    159162        unsigned int save_sr;
    160         unsigned int ltid = _get_current_task_id();
    161163
    162164        // activates BDV interrupt
    163165        _bdv_set_register( BLOCK_DEVICE_IRQ_ENABLE, 1 );
    164166
    165         // set _bdv_gtid
    166         _bdv_gtid = (procid<<16) + ltid;
     167        // set _bdv_trdid
     168        _bdv_trdid = _get_thread_trdid();
    167169
    168170        // enters critical section
     
    170172
    171173        // Set NORUN_MASK_IOC bit
    172         static_scheduler_t* psched  = (static_scheduler_t*)_schedulers[x][y][p];
    173         _atomic_or( &psched->context[ltid][CTX_NORUN_ID] , NORUN_MASK_IOC );
     174        static_scheduler_t* psched  = (static_scheduler_t*)_get_sched();
     175        unsigned int ltid = psched->current;
     176        _atomic_or( &psched->context[ltid].slot[CTX_NORUN_ID] , NORUN_MASK_IOC );
    174177       
    175178        // launch transfer
     
    184187#endif
    185188
    186         // deschedule task
     189        // deschedule thread
    187190        _ctx_switch();                     
    188191
     
    201204    }
    202205
    203     // release lock
     206    // release BDV lock and clear task context
    204207    _spin_lock_release( &_bdv_lock );     
     208    _atomic_and( &psched->context[ltid].slot[CTX_LOCKS_ID] , ~LOCKS_MASK_BDV );
    205209
    206210#if GIET_DEBUG_IOC
     
    241245    _bdv_status = status;
    242246
    243     // identify task waiting on BDV
    244     unsigned int procid  = _bdv_gtid>>16;
    245     unsigned int ltid    = _bdv_gtid & 0xFFFF;
    246     unsigned int cluster = procid >> P_WIDTH;
    247     unsigned int x       = cluster >> Y_WIDTH;
    248     unsigned int y       = cluster & ((1<<Y_WIDTH)-1);
    249     unsigned int p       = procid & ((1<<P_WIDTH)-1);
     247    // identify thread waiting on BDV
     248    unsigned int x       = (_bdv_trdid >> 24) & 0xFF;
     249    unsigned int y       = (_bdv_trdid >> 16) & 0xFF;
     250    unsigned int p       = (_bdv_trdid >>  8) & 0xFF;
     251    unsigned int ltid    = (_bdv_trdid      ) & 0xFF;
    250252
    251253    // Reset NORUN_MASK_IOC bit
    252254    static_scheduler_t* psched  = (static_scheduler_t*)_schedulers[x][y][p];
    253     unsigned int*       ptr     = &psched->context[ltid][CTX_NORUN_ID];
     255    unsigned int*       ptr     = &psched->context[ltid].slot[CTX_NORUN_ID];
    254256    _atomic_and( ptr , ~NORUN_MASK_IOC );
    255257
    256     // send a WAKUP WTI to processor running the sleeping task
    257     _xcu_send_wti( cluster,   
     258    // send a WAKUP WTI to processor running the sleeping thread
     259    _xcu_send_wti( (x<<Y_WIDTH) + y,
    258260                   p,
    259261                   0 );          // don't force context switch
     
    266268if ( _get_proctime() > GIET_DEBUG_IOC )
    267269_printf("\n[BDV DEBUG] Processor[%d,%d,%d] enters _bdv_isr() at cycle %d\n"
    268         "  for task %d running on P[%d,%d,%d] / bdv_status = %x\n",
     270        "  for thread %d running on P[%d,%d,%d] / bdv_status = %x\n",
    269271        c_x , c_y , c_p , _get_proctime() ,
    270272        ltid , x , y , p , status );
Note: See TracChangeset for help on using the changeset viewer.