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_common/utils.c

    r618 r709  
    1616#include <ctx_handler.h>
    1717
    18 // This variable is allocated in the boot.c file or in kernel_init.c file
    19 extern static_scheduler_t* _schedulers[X_SIZE][Y_SIZE][NB_PROCS_MAX];
     18// This variable is allocated in boot.c file or in kernel_init.c file
     19extern static_scheduler_t*  _schedulers[X_SIZE][Y_SIZE][NB_PROCS_MAX];
    2020
    2121///////////////////////////////////////////////////////////////////////////
     
    2323///////////////////////////////////////////////////////////////////////////
    2424
    25 /////////////////////////
    26 unsigned int _get_sched()
     25////////////////////////////////
     26static_scheduler_t* _get_sched()
    2727{
    2828    unsigned int ret;
    2929    asm volatile( "mfc0      %0,     $4,2    \n"
    3030                  : "=r"(ret) );
    31     return ret;
     31
     32    return (static_scheduler_t*)ret;
    3233}
    3334///////////////////////
     
    411412
    412413////////////////////////////////////////////////////////////////////////////
    413 //           Scheduler and tasks context access functions
     414//           Scheduler and threads context access functions
    414415////////////////////////////////////////////////////////////////////////////
    415416
    416417
    417 ///////////////////////////////////
    418 unsigned int _get_current_task_id()
    419 {
    420     static_scheduler_t * psched = (static_scheduler_t *) _get_sched();
    421     return (unsigned int) (psched->current);
     418///////////////////////////////
     419unsigned int _get_thread_ltid()
     420{
     421    static_scheduler_t* psched = (static_scheduler_t *) _get_sched();
     422    return psched->current;
     423}
     424
     425////////////////////////////////
     426unsigned int _get_thread_trdid()
     427{
     428    static_scheduler_t* psched  = (static_scheduler_t *) _get_sched();
     429    unsigned int        current = psched->current;
     430    return psched->context[current].slot[CTX_TRDID_ID];
     431}
     432
     433//////////////////////////////////////////////
     434unsigned int _get_thread_slot( unsigned int x,
     435                               unsigned int y,
     436                               unsigned int p,
     437                               unsigned int ltid,
     438                               unsigned int slotid )
     439{
     440    static_scheduler_t* psched  = (static_scheduler_t*)_schedulers[x][y][p];
     441    return psched->context[ltid].slot[slotid];
     442}
     443
     444//////////////////////////////////////
     445void _set_thread_slot( unsigned int x,
     446                       unsigned int y,
     447                       unsigned int p,
     448                       unsigned int ltid,
     449                       unsigned int slotid,
     450                       unsigned int value )
     451{
     452    static_scheduler_t* psched  = (static_scheduler_t*)_schedulers[x][y][p];
     453    psched->context[ltid].slot[slotid] = value;
     454}
     455
     456/////////////////////////////////////////////////////
     457unsigned int _get_context_slot( unsigned int slotid )
     458{
     459    static_scheduler_t* psched  = (static_scheduler_t*)_get_sched();
     460    unsigned int        ltid    = psched->current;
     461    return psched->context[ltid].slot[slotid];
    422462}
    423463
    424464////////////////////////////////////////////
    425 unsigned int _get_task_slot( unsigned int x,
    426                              unsigned int y,
    427                              unsigned int p,
    428                              unsigned int ltid,
    429                              unsigned int slot )
    430 {
    431     static_scheduler_t* psched  = (static_scheduler_t*)_schedulers[x][y][p];
    432     return psched->context[ltid][slot];
    433 }
    434 
    435 ////////////////////////////////////
    436 void _set_task_slot( unsigned int x,
    437                      unsigned int y,
    438                      unsigned int p,
    439                      unsigned int ltid,
    440                      unsigned int slot,
    441                      unsigned int value )
    442 {
    443     static_scheduler_t* psched  = (static_scheduler_t*)_schedulers[x][y][p];
    444     psched->context[ltid][slot] = value;
    445 }
    446 
    447 ///////////////////////////////////////////////////
    448 unsigned int _get_context_slot( unsigned int slot )
     465void _set_context_slot( unsigned int slotid,
     466                        unsigned int value )
    449467{
    450468    static_scheduler_t* psched  = (static_scheduler_t*)_get_sched();
    451     unsigned int        task_id = psched->current;
    452     return psched->context[task_id][slot];
    453 }
    454 
    455 ///////////////////////////////////////////
    456 void _set_context_slot( unsigned int slot,
    457                        unsigned int value )
    458 {
    459     static_scheduler_t* psched  = (static_scheduler_t*)_get_sched();
    460     unsigned int        task_id = psched->current;
    461     psched->context[task_id][slot] = value;
     469    unsigned int        ltid    = psched->current;
     470    psched->context[ltid].slot[slotid] = value;
    462471}
    463472
     
    496505            MAPPING_VSPACE_SIZE * header->vspaces);
    497506}
    498 //////////////////////////////////////////////////////////
    499 mapping_task_t * _get_task_base(mapping_header_t * header)
    500 {
    501     return (mapping_task_t *) ((char *) header +
     507//////////////////////////////////////////////////////////////
     508mapping_thread_t * _get_thread_base(mapping_header_t * header)
     509{
     510    return (mapping_thread_t *) ((char *) header +
    502511            MAPPING_HEADER_SIZE +
    503512            MAPPING_CLUSTER_SIZE * X_SIZE * Y_SIZE +
     
    515524            MAPPING_VSPACE_SIZE * header->vspaces +
    516525            MAPPING_VSEG_SIZE * header->vsegs +
    517             MAPPING_TASK_SIZE * header->tasks);
     526            MAPPING_THREAD_SIZE * header->threads);
    518527}
    519528///////////////////////////////////////////////////////
     
    526535            MAPPING_VSPACE_SIZE * header->vspaces +
    527536            MAPPING_VSEG_SIZE * header->vsegs +
    528             MAPPING_TASK_SIZE * header->tasks +
     537            MAPPING_THREAD_SIZE * header->threads +
    529538            MAPPING_PROC_SIZE * header->procs);
    530539}
     
    538547            MAPPING_VSPACE_SIZE * header->vspaces +
    539548            MAPPING_VSEG_SIZE * header->vsegs +
    540             MAPPING_TASK_SIZE * header->tasks +
     549            MAPPING_THREAD_SIZE * header->threads +
    541550            MAPPING_PROC_SIZE * header->procs +
    542551            MAPPING_IRQ_SIZE * header->irqs);
Note: See TracChangeset for help on using the changeset viewer.