Ejemplo n.º 1
0
Archivo: rcS.c Proyecto: asac/procd
int rcS(char *pattern, char *param, void (*q_empty)(struct runqueue *))
{
	runqueue_init(&q);
	q.empty_cb = q_empty;
	q.max_running_tasks = 1;

	return _rc(&q, "/etc/rc.d", pattern, "*", param);
}
Ejemplo n.º 2
0
kstat_t krhino_init(void)
{
    g_sys_stat = RHINO_STOPPED;

#if (RHINO_CONFIG_USER_HOOK > 0)
    krhino_init_hook();
#endif

    runqueue_init(&g_ready_queue);

    tick_list_init();

#if (RHINO_CONFIG_SYSTEM_STATS > 0)
    kobj_list_init();
#endif

#if (RHINO_CONFIG_MM_TLF > 0)
    k_mm_init();
#endif

#if (RHINO_CONFIG_KOBJ_DYN_ALLOC > 0)
    klist_init(&g_res_list);
    krhino_sem_create(&g_res_sem, "res_sem", 0);
    dyn_mem_proc_task_start();
#endif

#if (RHINO_CONFIG_CPU_NUM > 1)
    for (uint8_t i = 0; i < RHINO_CONFIG_CPU_NUM; i++) {
        krhino_task_cpu_create(&g_idle_task[i], "idle_task", NULL, RHINO_IDLE_PRI, 0,
                               &g_idle_task_stack[i][0], RHINO_CONFIG_IDLE_TASK_STACK_SIZE,
                               idle_task, i, 1u);
    }
#else
    krhino_task_create(&g_idle_task[0], "idle_task", NULL, RHINO_IDLE_PRI, 0,
                       &g_idle_task_stack[0][0], RHINO_CONFIG_IDLE_TASK_STACK_SIZE,
                       idle_task, 1u);
#endif

#if (RHINO_CONFIG_WORKQUEUE > 0)
    workqueue_init();
#endif

#if (RHINO_CONFIG_TIMER > 0)
    ktimer_init();
#endif

#if (RHINO_CONFIG_CPU_USAGE_STATS > 0)
    cpu_usage_stats_start();
#endif

    rhino_stack_check_init();

    return RHINO_SUCCESS;
}
Ejemplo n.º 3
0
/**
 * @brief Allocate user-stacks and initializes the kernel contexts of the
 * given threads.
 *
 * This function assumes that:
 * - num_tasks < number of tasks allowed on the system.
 * - the tasks have already been deemed schedulable and have been appropriately
 *   scheduled.  In particular, this means that the task list is sorted in order
 *   of priority -- higher priority tasks come first.
 *
 * @param tasks  A list of scheduled task descriptors.
 * @param size   The number of tasks is the list.
 */
void allocate_tasks(task_t** ptasks, size_t num_tasks)
{
	//set up system tcb for each task in 'tasks' - loop through each task
	uint8_t i;
	runqueue_init();
	dev_init();
	for(i = 1; i <= num_tasks; i++)
	{
		tcb_init(ptasks[i], &system_tcb[i], i);
		runqueue_add(&system_tcb[i], i);
	}

	/* add the idle task */
	idle_init();
}
Ejemplo n.º 4
0
/**
 * @brief Allocate user-stacks and initializes the kernel contexts of the
 * given threads.
 *
 * This function assumes that:
 * - num_tasks < number of tasks allowed on the system.
 * - the tasks have already been deemed schedulable and have been appropriately
 *   scheduled.  In particular, this means that the task list is sorted in order
 *   of priority -- higher priority tasks come first.
 *
 * @param tasks  A list of scheduled task descriptors.
 * @param size   The number of tasks is the list.
 */
void allocate_tasks(task_t** tasks, size_t num_tasks)
{
  size_t i = 1;
  for(; i <= num_tasks; i++)
  {
    tcb_t *task_tcb = &(system_tcb[i]);
    task_tcb->native_prio = i;
    task_tcb->cur_prio = i;  

    // Context
    sched_context_t *ctx = &(task_tcb->context);
    ctx->r4 = (uint32_t) (tasks[i-1]->lambda);

    ctx->r5 = (uint32_t) (tasks[i-1]->data);
    ctx->r6 = (uint32_t) (tasks[i-1]->stack_pos);
    ctx->r8 = global_data;
    ctx->sp = ((char *)(task_tcb->kstack) + OS_KSTACK_SIZE);
    // Easy way to launch task fo first time
    ctx->lr = (void *)launch_task;

    task_tcb->holds_lock = 0;
    task_tcb->sleep_queue = (tcb_t *)0;

  }

  initialize_idle();
  runqueue_init();
  
  runqueue_add(&(system_tcb[IDLE_PRIO]), IDLE_PRIO);
  for(i=1; i <= num_tasks; i++)
  {
    runqueue_add(&(system_tcb[i]), i);
  }
  // Set current tcb as IDLE
  dispatch_init(&(system_tcb[IDLE_PRIO]));
  
}
Ejemplo n.º 5
0
Archivo: rcS.c Proyecto: asac/procd
static void __attribute__((constructor)) rc_init() {
	runqueue_init(&r);
	r.empty_cb = r_empty;
	r.max_running_tasks = 8;
}
Ejemplo n.º 6
0
void scripts_init(void)
{
	runqueue_init(&runq);
	runq.max_running_tasks = 1;
}