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/hba_driver.c

    r657 r709  
    4646sqt_lock_t          _hba_allocator_lock  __attribute__((aligned(64)));
    4747
    48 // state of each slot (allocated to a task or not)
     48// state of each slot (allocated to a thread or not)
    4949// access must be protected by the allocator_lock in descheduling mode
    5050__attribute__((section(".kdata")))
     
    5656unsigned int        _hba_active_cmd[32];
    5757
    58 // global index of the task, for each entry in the command list
    59 __attribute__((section(".kdata")))
    60 unsigned int        _hba_gtid[32];
     58// global index of the thread, for each entry in the command list
     59__attribute__((section(".kdata")))
     60unsigned int        _hba_trid[32];
    6161
    6262// status of HBA commands
     
    9797
    9898///////////////////////////////////////////////////////////////////////////////
    99 // This blocking fonction allocates a free command index to the task.
     99// This blocking fonction allocates a free command index to the thread.
    100100// The hba_allocator_lock is not used in boot mode.
    101101// It returns the allocated command index (between 0 and 31)
     
    132132///////////////////////////////////////////////////////////////////////////////
    133133// This function releases the command index in the hba_allocated_cmd table.
    134 // There is no need to take the lock because only the task which owns the
     134// There is no need to take the lock because only the thread which owns the
    135135// command can release it.
    136136// return 0 if success, -1 if error
     
    281281
    282282    /////////////////////////////////////////////////////////////////
    283     // in descheduling mode, we deschedule the task
    284     // and use an interrupt to reschedule the task.
     283    // in descheduling mode, we deschedule the thread
     284    // and use an interrupt to reschedule the thread.
    285285    // We need a critical section, because we must set the NORUN bit
    286286        // before to launch the transfer, and we don't want to be
     
    297297#endif
    298298        unsigned int save_sr;
    299         unsigned int ltid = _get_current_task_id();
     299        unsigned int ltid = _get_thread_ltid();
    300300
    301301        // activates HBA interrupts
    302302        _hba_set_register( HBA_PXIE , 0x00000001 );
    303303
    304         // set _hba_gtid[cmd_id]
    305         _hba_gtid[cmd_id] = (procid<<16) + ltid;
     304        // set _hba_trid[cmd_id]
     305        _hba_trid[cmd_id] = (x<<24) + (y<<16) + (p<<8) + ltid;
    306306
    307307        // enters critical section
     
    310310        // Set NORUN_MASK_IOC bit
    311311        static_scheduler_t* psched  = (static_scheduler_t*)_schedulers[x][y][p];
    312         unsigned int*       ptr     = &psched->context[ltid][CTX_NORUN_ID];
     312        unsigned int*       ptr     = &psched->context[ltid].slot[CTX_NORUN_ID];
    313313        _atomic_or( ptr , NORUN_MASK_IOC );
    314314     
     
    319319        _hba_active_cmd[cmd_id] = 1;
    320320
    321         // deschedule task
     321        // deschedule thread
    322322        _ctx_switch();                     
    323323
    324324#if GIET_DEBUG_IOC
    325325if (_get_proctime() > GIET_DEBUG_IOC)
    326 _printf("\n[DEBUG HBA] _hba_access() : task %d on P[%d,%d,%d] resume at cycle %d\n",
     326_printf("\n[DEBUG HBA] _hba_access() : thread %d on P[%d,%d,%d] resume at cycle %d\n",
    327327        ltid , x , y , p , _get_proctime() );
    328328#endif
     
    438438            _hba_active_cmd[cmd_id] = 0;
    439439
    440             // identify waiting task
    441             unsigned int procid  = _hba_gtid[cmd_id]>>16;
    442             unsigned int ltid    = _hba_gtid[cmd_id] & 0xFFFF;
    443             unsigned int cluster = procid >> P_WIDTH;
    444             unsigned int x       = cluster >> Y_WIDTH;
    445             unsigned int y       = cluster & ((1<<Y_WIDTH)-1);
    446             unsigned int p       = procid & ((1<<P_WIDTH)-1);
     440            // identify waiting thread
     441            unsigned int x       = (_hba_trid[cmd_id]>>24) & 0xFF;
     442            unsigned int y       = (_hba_trid[cmd_id]>>16) & 0xFF;
     443            unsigned int p       = (_hba_trid[cmd_id]>> 8) & 0xFF;
     444            unsigned int ltid    = (_hba_trid[cmd_id]    ) & 0xFF;
    447445 
    448446            // Reset NORUN_MASK_IOC bit
    449447            static_scheduler_t* psched  = (static_scheduler_t*)_schedulers[x][y][p];
    450             _atomic_and( &psched->context[ltid][CTX_NORUN_ID] , ~NORUN_MASK_IOC );
    451 
    452             // send a WAKUP WTI to processor running the waiting task
    453             _xcu_send_wti( cluster ,
     448            _atomic_and( &psched->context[ltid].slot[CTX_NORUN_ID] , ~NORUN_MASK_IOC );
     449
     450            // send a WAKUP WTI to processor running the waiting thread
     451            _xcu_send_wti( (x<<Y_WIDTH) + y,
    454452                           p ,
    455453                           0 );          // don't force context switch
     
    458456if (_get_proctime() > GIET_DEBUG_IOC)
    459457_printf("\n[DEBUG HBA] _hba_isr() : command %d completed at cycle %d\n"
    460         "  resume task %d running on P[%d,%d,%d]\n",
     458        "  resume thread %d running on P[%d,%d,%d]\n",
    461459        cmd_id , _get_proctime() ,
    462460        ltid , x , y , p );
Note: See TracChangeset for help on using the changeset viewer.