Changeset 391 for soft/giet_vm


Ignore:
Timestamp:
Aug 11, 2014, 9:19:06 PM (10 years ago)
Author:
alain
Message:

Idle task stack implementation. The idle stack was previously implemented in the
seg_kernel data, and this was a scalabity bottleneck. i
A 4 Kbytes stack for idle stack is now implemented in the processor scheduler segment.

Location:
soft/giet_vm/giet_kernel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_kernel/ctx_handler.c

    r330 r391  
    103103void _idle_task()
    104104{
     105    unsigned int gpid       = _get_procid();
     106    unsigned int cluster_xy = gpid / NB_PROCS_MAX;
     107    unsigned int lpid       = gpid % NB_PROCS_MAX;
     108    unsigned int x          = cluster_xy >> Y_WIDTH;
     109    unsigned int y          = cluster_xy & ((1<<Y_WIDTH)-1);
     110
    105111    while(1)
    106112    {
     113        // initialize counter
    107114        unsigned int count = GIET_IDLE_TASK_PERIOD;
    108115
     
    119126
    120127        // warning message
    121         unsigned int gpid       = _get_procid();
    122         unsigned int cluster_xy = gpid / NB_PROCS_MAX;
    123         unsigned int lpid       = gpid % NB_PROCS_MAX;
    124         unsigned int x          = cluster_xy >> Y_WIDTH;
    125         unsigned int y          = cluster_xy & ((1<<Y_WIDTH)-1);
    126 
    127128        _printf("\n[GIET WARNING] Processor[%d,%d,%d] still idle at cycle %d\n",
    128129                x, y, lpid, _get_proctime() );
    129 
    130130    }
    131131} // end ctx_idle()
  • soft/giet_vm/giet_kernel/ctx_handler.h

    r310 r391  
    7070    unsigned int wti_vector[32];       // software interrupt vector
    7171    unsigned int reserved[30];         // padding to 4 Kbytes
     72    unsigned int idle_stack[1024];     // private stack for idle stack (4Kbytes)
    7273} static_scheduler_t;
    7374
    7475
    7576/////////////////////////////////////////////////////////////////////////////////
    76 //  "idle" task index definition
     77//  "idle" task index and stack size definition
    7778/////////////////////////////////////////////////////////////////////////////////
    7879
    7980#define IDLE_TASK_INDEX        13
     81#define IDLE_TASK_STACK        0x1000
    8082
    8183/////////////////////////////////////////////////////////////////////////////////
     
    107109
    108110//////////////////////////////////////////////////////////////////////////////////
    109 //     Prototype of the context switch function
     111//    context switch functions
    110112//////////////////////////////////////////////////////////////////////////////////
    111113
  • soft/giet_vm/giet_kernel/kernel_init.c

    r385 r391  
    1414// and where there is one physical memory bank per cluster.
    1515//
    16 // The kernel_init() function is executed in parallel by all procesors,
    17 // and completes the system initialisation that has been started by processor[0,0,0]
     16// The kernel_init() function is executed sequencially by all procesors.
     17// It completes the system initialisation that has been started by processor[0,0,0]
    1818// in the boot_init() function. It makes the following assuptions, regarding the work
    1919// bone by the boot code:
     
    100100
    101101#if !defined(IDLE_TASK_INDEX)
    102 # error: You must define IDLE_TASK_INDEX in the giet_config.h file
     102# error: You must define IDLE_TASK_INDEX in the ctx_handler.h file
     103#endif
     104
     105#if !defined(IDLE_TASK_STACK)
     106# error: You must define IDLE_TASK_STACK in the ctx_handler.h file
    103107#endif
    104108
     
    129133
    130134////////////////////////////////////////////////////////////////////////////////////
    131 // stacks for the "idle" tasks (64 bytes for each processor)
    132 ////////////////////////////////////////////////////////////////////////////////////
    133 
    134 __attribute__((section (".kdata")))
    135 volatile unsigned int _idle_stack[X_SIZE * Y_SIZE * NB_PROCS_MAX * 16 ];
    136 
    137 ////////////////////////////////////////////////////////////////////////////////////
    138 // Synchonisation Barrier before jumping to user code
     135// Synchonisation barrier before jumping to user code
    139136////////////////////////////////////////////////////////////////////////////////////
    140137
     
    155152    while( pid != _init_barrier ) asm volatile ( "nop" );
    156153
    157     // Step 1 : each processor get its scheduler virtual address
     154    // Step 1 : each processor get its scheduler virtual address from CP0 register
    158155    //          and contribute to initialise the _schedulers[] array
    159156
     
    290287
    291288    // step 6 : each processor updates the idle_task context:
    292     //          (only CTX_SP, CTX_RA, CTX_EPC).
    293     //          The stack size is 512 bytes, reserved in seg_kdata.
     289    //          (CTX_SP, CTX_RA, CTX_EPC).
     290    //          The 4 Kbytes idle stack is implemented in the scheduler.
    294291    //          The PTPR register, the CTX_PTPR and CTX_PTAB slots
    295292    //          have been initialised in boot code.
    296293
    297     unsigned int p = ((x * Y_SIZE) + y) * NB_PROCS_MAX + lpid;
    298 
    299     unsigned int stack = (unsigned int)_idle_stack + ((p + 1) * 64);
    300 
    301     _set_task_slot( global_pid, IDLE_TASK_INDEX, CTX_SP_ID,  stack);
     294    unsigned int pstack = ((unsigned int)psched) + 0x2000;
     295
     296    _set_task_slot( global_pid, IDLE_TASK_INDEX, CTX_SP_ID,  pstack);
    302297    _set_task_slot( global_pid, IDLE_TASK_INDEX, CTX_RA_ID,  (unsigned int) &_ctx_eret);
    303298    _set_task_slot( global_pid, IDLE_TASK_INDEX, CTX_EPC_ID, (unsigned int) &_idle_task);
    304299
    305300#if GIET_DEBUG_INIT
    306 _printf("\n[GIET DEBUG INIT] Processor[%d,%d,%d] initializes IDLE task\n",
    307         x, y, lpid );
     301_printf("\n[GIET DEBUG INIT] Processor[%d,%d,%d] initializes IDLE task\n"
     302        " - stack_base = %x\n"
     303        " - stack_size = 0x1000\n",
     304        x, y, lpid, pstack - 0x1000 );
    308305#endif
    309306
     
    341338    // busy waiting until all processors synchronized
    342339    while ( _init_barrier != NB_TOTAL_PROCS );
     340
     341#if GIET_DEBUG_INIT
     342_printf("\n[GIET DEBUG INIT] Processor[%d,%d,%d] initializes registers at cycle %d\n"
     343        " - sp   = %x\n"
     344        " - sr   = %x\n"
     345        " - ptpr = %x\n"
     346        " - epc  = %x\n",
     347        x, y, lpid, _get_proctime(),
     348        sp_value, sr_value, ptpr_value, epc_value );
     349#endif
    343350
    344351    // set registers and jump to user code
Note: See TracChangeset for help on using the changeset viewer.