Changeset 167 for soft/giet_vm/sys/ctx_handler.c
- Timestamp:
- Jul 16, 2012, 10:26:27 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/sys/ctx_handler.c
r165 r167 15 15 // It contains copies of processor registers, when the task is not running, 16 16 // and some general informations associated to the task. 17 // 17 18 // - It contains GPR[i], generally stored in slot (i). $0, *26 & $27 are not saved. 18 19 // - It contains HI & LO registers. 19 20 // - It contains CP0 registers: EPC, SR, CR. 20 21 // - It contains CP2 registers : PTPR and MODE. 21 // - It contains the TTY index for the terminal allocated to the task. 22 // ctx[0] <- SR ctx[8] <- $8 ctx[16]<- $16 ctx[24]<- $24 ctx[32]<- EPC 23 // ctx[1] <- $1 ctx[9] <- $9 ctx[17]<- $17 ctx[25]<- $25 ctx[33]<- CR 24 // ctx[2] <- $2 ctx[10]<- $10 ctx[18]<- $18 ctx[26]<- LO ctx[34]<- TTY 25 // ctx[3] <- $3 ctx[11]<- $11 ctx[19]<- $19 ctx[27]<- HI ctx[35]<- PTPR 26 // ctx[4] <- $4 ctx[12]<- $12 ctx[20]<- $20 ctx[28]<- $28 ctx[36]<- MODE 27 // ctx[5] <- $5 ctx[13]<- $13 ctx[21]<- $21 ctx[29]<- $29 ctx[37]<- FBDMA 28 // ctx[6] <- $6 ctx[14]<- $14 ctx[22]<- $22 ctx[30]<- $30 ctx[38]<- reserved 29 // ctx[7] <- $7 ctx[15]<- $15 ctx[23]<- $23 ctx[31]<- $31 ctx[39]<- reserved 22 // - It contains the TTY global index, the FBDMA global index, the virtual base 23 // address of the page table (PTAB), and the task global index (TASK). 24 // 25 // ctx[0]<- SR|ctx[8] <- $8 |ctx[16]<- $16|ctx[24]<- $24|ctx[32]<- EPC |ctx[40]<- TTY 26 // ctx[1]<- $1|ctx[9] <- $9 |ctx[17]<- $17|ctx[25]<- $25|ctx[33]<- CR |ctx[41]<- FBDMA 27 // ctx[2]<- $2|ctx[10]<- $10|ctx[18]<- $18|ctx[26]<- LO |ctx[34]<- *** |ctx[42]<- PTAB 28 // ctx[3]<- $3|ctx[11]<- $11|ctx[19]<- $19|ctx[27]<- HI |ctx[35]<- PTPR|ctx[43]<- TASK 29 // ctx[4]<- $4|ctx[12]<- $12|ctx[20]<- $20|ctx[28]<- $28|ctx[36]<- MODE|ctx[44]<- *** 30 // ctx[5]<- $5|ctx[13]<- $13|ctx[21]<- $21|ctx[29]<- SP |ctx[37]<- *** |ctx[45]<- *** 31 // ctx[6]<- $6|ctx[14]<- $14|ctx[22]<- $22|ctx[30]<- $30|ctx[38]<- *** |ctx[46]<- *** 32 // ctx[7]<- $7|ctx[15]<- $15|ctx[23]<- $23|ctx[31]<- RA |ctx[39]<- *** |ctx[47]<- *** 30 33 ///////////////////////////////////////////////////////////////////////////////////// 31 34 … … 40 43 41 44 ///////////////////////////////////////////////////////////////////////////////// 42 // Global variables 45 // Global variables : array of schedulers (one scheduler per processor) 43 46 ///////////////////////////////////////////////////////////////////////////////// 44 47 45 static_scheduler_t _scheduler[NB_CLUSTERS * NB_PROCS];48 __attribute__((section (".kdata"))) static_scheduler_t _scheduler[NB_CLUSTERS * NB_PROCS]; 46 49 47 50 ///////////////////////////////////////////////////////////////////////////////// … … 64 67 unsigned int *next_context; 65 68 66 unsigned int pid = _procid(); 67 unsigned int time = _proctime(); 68 unsigned int tasks = _scheduler[pid].tasks; 69 unsigned int proc_id = _procid(); 70 unsigned int tasks = _scheduler[proc_id].tasks; 69 71 70 72 // return if only one task */ … … 72 74 73 75 // compute the task context base address for the current task 74 curr_task_id = _scheduler[p id].current;75 curr_context = &(_scheduler[p id].context[curr_task_id][0]);76 curr_task_id = _scheduler[proc_id].current; 77 curr_context = &(_scheduler[proc_id].context[curr_task_id][0]); 76 78 77 79 // select the next task using a round-robin scheduling policy … … 79 81 80 82 // compute the task context base address for the next task 81 next_context = &(_scheduler[p id].context[next_task_id][0]);83 next_context = &(_scheduler[proc_id].context[next_task_id][0]); 82 84 83 85 #if GIET_DEBUG_SWITCH 84 86 _get_lock( &_tty_put_lock ); 85 87 _puts( "\n[GIET] Context switch for processor "); 86 _putw( p id );88 _putw( proc_id ); 87 89 _puts( " at cycle "); 88 _putw( time);90 _putw( _proctime() ); 89 91 _puts("\n"); 90 92 _puts( " - tasks = "); … … 101 103 102 104 // update the scheduler state, and makes the task switch 103 _scheduler[p id].current = next_task_id;105 _scheduler[proc_id].current = next_task_id; 104 106 _task_switch( curr_context, next_context ); 105 107
Note: See TracChangeset
for help on using the changeset viewer.