36 #ifdef POK_NEEDS_THREADS 
   48 #ifdef POK_NEEDS_SCHED_RMS 
   61     while ( j>= index_low && pok_threads[j].period > val.period)
 
   63         pok_threads[j+1] = pok_threads[j];
 
   75 void pok_thread_init(
void)
 
   79 #ifdef POK_NEEDS_PARTITIONS 
   87       total_threads = total_threads + pok_partitions[j].nthreads;
 
   90 #if defined (POK_NEEDS_DEBUG) || defined (POK_NEEDS_ERROR_HANDLING) 
   93 #ifdef POK_NEEDS_DEBUG 
   94       printf (
"Error in configuration, bad number of threads\n");
 
   96 #ifdef POK_NEEDS_ERROR_HANDLING 
   97       pok_kernel_error (POK_ERROR_KIND_KERNEL_CONFIG);
 
  103    pok_threads[KERNEL_THREAD].priority     = pok_sched_get_priority_min(0);
 
  104    pok_threads[KERNEL_THREAD].state                = POK_STATE_RUNNABLE;
 
  105    pok_threads[KERNEL_THREAD].next_activation = 0;
 
  107    pok_threads[IDLE_THREAD].period                     = 0;
 
  108    pok_threads[IDLE_THREAD].deadline                   = 0;
 
  109    pok_threads[IDLE_THREAD].time_capacity              = 0;
 
  110    pok_threads[IDLE_THREAD].next_activation            = 0;
 
  111    pok_threads[IDLE_THREAD].remaining_time_capacity    = 0;
 
  112    pok_threads[IDLE_THREAD].wakeup_time                = 0;
 
  114    pok_threads[IDLE_THREAD].priority                   = pok_sched_get_priority_min(0);
 
  115    pok_threads[IDLE_THREAD].state                      = POK_STATE_RUNNABLE;
 
  118                                                    (IDLE_THREAD,                                                                             IDLE_STACK_SIZE,
 
  123       pok_threads[i].period                     = 0;
 
  124       pok_threads[i].deadline                   = 0;
 
  125       pok_threads[i].time_capacity              = 0;
 
  126       pok_threads[i].remaining_time_capacity    = 0;
 
  127       pok_threads[i].next_activation            = 0;
 
  128       pok_threads[i].wakeup_time                = 0;
 
  129       pok_threads[i].state                      = POK_STATE_STOPPED;
 
  133 #ifdef POK_NEEDS_PARTITIONS 
  141                                        const pok_thread_attr_t*   attr,
 
  149    if (  (pok_partitions[partition_id].mode != POK_PARTITION_MODE_INIT_COLD) &&
 
  150          (pok_partitions[partition_id].mode != POK_PARTITION_MODE_INIT_WARM) )
 
  155    if (pok_partitions[partition_id].thread_index >= pok_partitions[partition_id].thread_index_high)
 
  157 #ifdef POK_NEEDS_ERROR_HANDLING 
  158       POK_ERROR_CURRENT_PARTITION (POK_ERROR_KIND_PARTITION_CONFIGURATION);
 
  163    id = pok_partitions[partition_id].thread_index_low +  pok_partitions[partition_id].thread_index;
 
  164    pok_partitions[partition_id].thread_index =  pok_partitions[partition_id].thread_index + 1;
 
  166     if ((attr->priority <= pok_sched_get_priority_max (pok_partitions[partition_id].sched)) && (attr->priority >= pok_sched_get_priority_min (pok_partitions[partition_id].sched)))
 
  168       pok_threads[id].priority      = attr->priority;
 
  171    if (attr->period > 0)
 
  173       pok_threads[id].period          = attr->period;
 
  174       pok_threads[id].next_activation = attr->period;
 
  177    if (attr->deadline > 0)
 
  179       pok_threads[id].deadline      = attr->deadline;
 
  182 #ifdef POK_NEEDS_SCHED_HFPPS 
  183    pok_threads[id].payback = 0;
 
  186    if (attr->time_capacity > 0)
 
  188       pok_threads[id].time_capacity = attr->time_capacity;
 
  189       pok_threads[id].remaining_time_capacity = attr->time_capacity;
 
  193       pok_threads[id].remaining_time_capacity   = POK_THREAD_DEFAULT_TIME_CAPACITY;
 
  194       pok_threads[id].time_capacity             = POK_THREAD_DEFAULT_TIME_CAPACITY;
 
  199    pok_threads[id].state                   = POK_STATE_RUNNABLE;
 
  200    pok_threads[id].wakeup_time   = 0;
 
  211    pok_threads[id].partition        = partition_id; 
 
  212    pok_threads[id].entry            = attr->entry;
 
  213    pok_threads[id].init_stack_addr  = stack_vaddr;
 
  216 #ifdef POK_NEEDS_SCHED_RMS 
  217    if ((pok_partitions[partition_id].sched == 
POK_SCHED_RMS) && (
id > pok_partitions[partition_id].thread_index_low))
 
  219       pok_thread_insert_sort(pok_partitions[partition_id].thread_index_low+1,
id);
 
  223 #ifdef POK_NEEDS_INSTRUMENTATION 
  224       pok_instrumentation_task_archi (
id);
 
  236 void pok_thread_start(
void (*entry)(), 
unsigned int id)
 
  242 #ifdef POK_NEEDS_THREAD_SLEEP 
  246    mytime = time + POK_GETTICK();
 
  247    pok_sched_lock_current_thread_timed (mytime);
 
  253 #ifdef POK_NEEDS_THREAD_SLEEP_UNTIL 
  256    pok_sched_lock_current_thread_timed ((
uint64_t)time);
 
  262 #if defined (POK_NEEDS_THREAD_SUSPEND) || defined (POK_NEEDS_ERROR_HANDLING) 
  265    pok_sched_stop_self ();
 
  271 #ifdef POK_NEEDS_ERROR_HANDLING 
  278    pok_threads[tid].remaining_time_capacity  = pok_threads[tid].time_capacity;
 
  279    pok_threads[tid].state                    = POK_STATE_WAIT_NEXT_ACTIVATION;
 
  280    pok_threads[tid].wakeup_time              = 0;
 
  295                                                              pok_threads[tid].init_stack_addr,
 
  305   if (POK_CURRENT_PARTITION.thread_index_low > 
id || POK_CURRENT_PARTITION.thread_index_high < 
id)
 
  307   attr->deadline = pok_threads[id].end_time;
 
  308   attr->state = pok_threads[id].state;
 
  309   attr->priority = pok_threads[id].priority;
 
  310   attr->entry = pok_threads[id].entry;
 
  311   attr->period = pok_threads[id].period;
 
  312   attr->time_capacity = pok_threads[id].time_capacity;
 
  313   attr->stack_size = POK_USER_STACK_SIZE;