Ejemplo n.º 1
0
Archivo: init.c Proyecto: gedare/rtems
static void Init(rtems_task_argument arg)
{
  test_context *ctx = &test_instance;

  TEST_BEGIN();

  ctx->low = rtems_task_self();

  create_task(&ctx->mid, 3);
  create_task(&ctx->high, 1);
  create_task(&ctx->inversion, 2);
  create_sema(&ctx->sem_a);
  create_sema(&ctx->sem_b);

  obtain_sema(ctx->sem_a);
  start_task(ctx->mid, mid_task);
  start_task(ctx->high, high_task);

  /*
   * Here we see that the priority of the high priority task blocked on
   * semaphore B propagated to the low priority task owning semaphore A
   * on which the owner of semaphore B depends.
   */
  assert_prio(ctx->low, 1);
  assert_prio(ctx->mid, 1);
  assert_prio(ctx->high, 1);
  assert_prio(ctx->inversion, 2);

  TEST_END();
  rtems_test_exit(0);
}
Ejemplo n.º 2
0
static void test_unblock_op(void)
{
  rtems_status_code sc;
  rtems_id task_id;
  Thread_Control *executing;
  Scheduler_SMP_Node *executing_node;
  Thread_Control *other;
  size_t i;

  task_id = start_task(3);

  _Thread_Disable_dispatch();

  executing = _Thread_Executing;
  executing_node = _Scheduler_SMP_Thread_get_node(executing);

  other = get_thread_by_id(task_id);

  for (i = 0; i < RTEMS_ARRAY_SIZE(states); ++i) {
    test_case_unblock_op(
      executing,
      executing_node,
      other,
      states[i]
    );
  }

  _Thread_Change_priority(executing, 1, true);
  rtems_test_assert(executing_node->state == SCHEDULER_SMP_NODE_SCHEDULED);

  _Thread_Enable_dispatch();

  sc = rtems_task_delete(task_id);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
Ejemplo n.º 3
0
Archivo: init.c Proyecto: gedare/rtems
static void high_task(rtems_task_argument arg)
{
  test_context *ctx = &test_instance;

  start_task(ctx->inversion, inversion_task);
  obtain_sema(ctx->sem_b);
}
Ejemplo n.º 4
0
static void test(void)
{
  test_context *ctx = &test_instance;
  rtems_status_code sc;

  ctx->tasks[M] = rtems_task_self();
  start_task(ctx, A_1, worker, 1);
  start_task(ctx, A_2_0, worker, 2);
  start_task(ctx, A_2_1, worker, 2);
  start_task(ctx, H, helper, 3);

  sc = rtems_semaphore_create(
    rtems_build_name(' ', 'M', 'T', 'X'),
    1,
    RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY,
    0,
    &ctx->mtx
  );
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);

  obtain(ctx);
  request(ctx, A_1, REQ_MTX_OBTAIN);
  check_generations(ctx, NONE, NONE);
  assert_prio(ctx, M, 1);
  release(ctx);
  check_generations(ctx, A_1, NONE);
  assert_prio(ctx, M, 3);
  request(ctx, A_1, REQ_MTX_RELEASE);
  check_generations(ctx, A_1, NONE);

  obtain(ctx);
  request(ctx, A_2_0, REQ_MTX_OBTAIN);
  request(ctx, A_1, REQ_MTX_OBTAIN);
  request(ctx, A_2_1, REQ_MTX_OBTAIN);
  check_generations(ctx, NONE, NONE);
  assert_prio(ctx, M, 1);
  release(ctx);
  check_generations(ctx, A_1, NONE);
  assert_prio(ctx, M, 3);
  assert_prio(ctx, A_1, 1);
  request(ctx, A_1, REQ_MTX_RELEASE);
  check_generations(ctx, A_1, A_2_0);
  request(ctx, A_2_0, REQ_MTX_RELEASE);
  check_generations(ctx, A_2_0, A_2_1);
  request(ctx, A_2_1, REQ_MTX_RELEASE);
  check_generations(ctx, A_2_1, NONE);
}
Ejemplo n.º 5
0
Archivo: task01.c Proyecto: apense/qse
static int test_main (int argc, qse_char_t* argv[])
{
	int ret;

	ret  = start_task (print);
	qse_printf (QSE_T("== END ==\n"));

	return ret;
}
Ejemplo n.º 6
0
static void Init(rtems_task_argument arg)
{
  test_context *ctx = &test_instance;

  TEST_BEGIN();

  ctx->low = rtems_task_self();

  create_task(&ctx->mid, 3);
  create_task(&ctx->high, 1);
  create_task(&ctx->inversion, 2);
  create_sema(&ctx->sem_a);
  create_sema(&ctx->sem_b);

  obtain_sema(ctx->sem_a);
  start_task(ctx->mid, mid_task);
  start_task(ctx->high, high_task);
}
Ejemplo n.º 7
0
// have to manage the task stack explicitly
void TimeTasks::start_task(TimeTasks::Tasks taskid, double start_time)
{
  if(!is_output_thread()) return;
  if(stack_depth[taskid]==0)
  {
    start_times[taskid]=start_time;
    start_task(taskid);
  }
  stack_depth[taskid]++;
}
Ejemplo n.º 8
0
static void mainproc(void *arg)
{
    Dynamic    *dynamicp;
    Gfx        *glistp;
    Control    cont;

    init_dma();
    init_task();
    init_framebuffer();

    read_rom( _staticSegmentStart,
              _staticSegmentRomStart, _staticSegmentRomEnd  );
    read_rom( _dkSegmentStart, _dkSegmentRomStart, _dkSegmentRomEnd  );
    read_rom( _dk7SegmentStart, _dk7SegmentRomStart, _dk7SegmentRomEnd  );
    read_rom( _roadSegmentStart, _roadSegmentRomStart,
              _roadSegmentRomEnd  );
    read_rom( _l2_tvSegmentStart, _l2_tvSegmentRomStart,
              _l2_tvSegmentRomEnd  );

    init_controlers( &cont );

    game_init();

    while (1)
    {
        read_controler( &cont );

        dynamicp = &dynamic;

        guOrtho( &dynamicp->projection,
                 -(float) SCREEN_WD / 2.0F, (float) SCREEN_WD / 2.0F,
                 -(float) SCREEN_HT / 2.0F, (float) SCREEN_HT / 2.0F,
                 1.0F, 10.0F, 1.0F );
        guRotate( &dynamicp->modeling, 0.0F, 0.0F, 0.0F, 1.0F );

        glistp = dynamicp->glist;

        /* rcp rdp & color frame buffer initialize */
        glistp = init_rcprdp( glistp, (char *)_staticSegmentStart, draw_buffer );
        glistp = clear_cfb( glistp );

        /* game main */
        glistp = game_main( glistp, &cont );

        gDPFullSync(glistp++);
        gSPEndDisplayList(glistp++);

        assert((glistp - dynamicp->glist) < GLIST_LEN);

        start_task( glistp, dynamicp );

        swap_framebuffer( draw_buffer );
        draw_buffer ^= 1;
    }
}
Ejemplo n.º 9
0
int main(int argc, char* argv[]){

	initialize_block(argc,argv,sizeof(struct global_settings),1,0);

	start_task(gs->task_prio,&loop);

	wait_for_task_end();
	
	finalize_block();

	return 0;
}
Ejemplo n.º 10
0
int main(void)
//   Input    : -
//   Output   : -
//   Function : main function. Runs the init function and then loops


{
    //Initialization
    disable_global_int();
    SysTick_init();
    GPIO_init();
    swtimers_init();
    RTCS_init();

    UART0_init(19200, 8, 1, 0);
    enable_global_int();
    LCD_init();
    queue_init(&display_lcd_queue);
    queue_init(&uart0_rx_queue);
    numpad_init();

    open_queue(Q_LCD);
    open_queue(Q_INPUT);

    start_task( TASK_RTC, RTC_task);
    start_task( TASK_DISPLAY, display_task);
    start_task( TASK_LCD, LCD_task);
    start_task( TASK_NUMPAD, numpad_task);
    start_task( TASK_UI, ui_task);
    start_task( TASK_UART0, UART0_task);

    schedule();

    return (0);
}
Ejemplo n.º 11
0
/**
 * gst_task_set_state:
 * @task: a #GstTask
 * @state: the new task state
 *
 * Sets the state of @task to @state.
 *
 * The @task must have a lock associated with it using
 * gst_task_set_lock() when going to GST_TASK_STARTED or GST_TASK_PAUSED or
 * this function will return %FALSE.
 *
 * MT safe.
 *
 * Returns: %TRUE if the state could be changed.
 *
 * Since: 0.10.24
 */
gboolean
gst_task_set_state (GstTask * task, GstTaskState state)
{
  GstTaskState old;
  gboolean res = TRUE;

  g_return_val_if_fail (GST_IS_TASK (task), FALSE);

  GST_DEBUG_OBJECT (task, "Changing task %p to state %d", task, state);

  GST_OBJECT_LOCK (task);
  if (state != GST_TASK_STOPPED)
    if (G_UNLIKELY (GST_TASK_GET_LOCK (task) == NULL))
      goto no_lock;

  /* if the state changed, do our thing */
  old = task->state;
  if (old != state) {
    task->state = state;
    switch (old) {
      case GST_TASK_STOPPED:
        /* If the task already has a thread scheduled we don't have to do
         * anything. */
        if (G_UNLIKELY (!task->running))
          res = start_task (task);
        break;
      case GST_TASK_PAUSED:
        /* when we are paused, signal to go to the new state */
        GST_TASK_SIGNAL (task);
        break;
      case GST_TASK_STARTED:
        /* if we were started, we'll go to the new state after the next
         * iteration. */
        break;
    }
  }
  GST_OBJECT_UNLOCK (task);

  return res;

  /* ERRORS */
no_lock:
  {
    GST_WARNING_OBJECT (task, "state %d set on task without a lock", state);
    GST_OBJECT_UNLOCK (task);
    g_warning ("task without a lock can't be set to state %d", state);
    return FALSE;
  }
}
Ejemplo n.º 12
0
void init() {
	SYSCALL_ENABLED =	0;
	SLEEP_ENABLED =		0;

	// Initialise all the ISRs and segmentation
	runModule ( &init_descriptor_tables );

	asm volatile ( "sti" );
	runModule ( &initialise_syscalls );

	runModule ( &init_Interupts );

	// Initialise the PIT to 50Hz
	asm volatile ( "sti" );
	init_timer ( 50 );
	asm volatile ( "sti" );

	runModule ( &init_file_system );

	runModule ( &locate_initrd );

	// Start paging.
	runModule ( &initialise_paging );

	runModule ( &init_keyboard );

	datetime_t system_time = getDatetime();

	printf ( "[Time] is %d:%d:%d %d/%d/%d\n", system_time.sec, system_time.min, system_time.hour, system_time.day, system_time.month, system_time.year );

	// Start multitasking.
	runModule ( &initialise_tasking );
	enable_tasking();
	monitor_set_fore_colour ( 12 );
	printf ( "%s pid is: %d\n", gettaskname(), getpid() );
	start_task ( 200, 10, clock, 0, "UserClock" );
	//sleep ( 1 );
	monitor_set_fore_colour ( 15 );

	runModule ( &init_sound_multitsk );

	printf ( "running flat binary at 0x500000\n" );
	load_flat ( "flat.bin", 0x500000 );
	load_flat ( "flat2.bin", 0x501000 );

	//runModule ( &switch_to_user_mode);

}
Ejemplo n.º 13
0
int ACE_TMAIN (int argc, ACE_TCHAR* argv[])
{
    char sinput[10]; 

    show_menu(); 

    scanf("%s",sinput); 
    while(strcmp(sinput,"q")!=0) 
    { 
        if(strcmp(sinput,"s")==0) 
        { 
            start_task();
        }

        //input command 
        printf("$ input command >"); 
        scanf("%s",sinput); 
    }

    return 0;
}
Ejemplo n.º 14
0
static void test_change_priority(void)
{
  rtems_status_code sc;
  rtems_id task_id;
  Thread_Control *executing;
  Scheduler_SMP_Node *node;
  size_t i;
  size_t j;
  size_t k;

  task_id = start_task(3);

  _Thread_Disable_dispatch();

  executing = _Thread_Executing;
  node = _Scheduler_SMP_Thread_get_node( executing );

  for (i = 0; i < RTEMS_ARRAY_SIZE(states); ++i) {
    for (j = 0; j < RTEMS_ARRAY_SIZE(priorities); ++j) {
      for (k = 0; k < RTEMS_ARRAY_SIZE(prepend_it); ++k) {
        test_case_change_priority(
          executing,
          node,
          states[i],
          priorities[j],
          prepend_it[k],
          states[j]
        );
      }
    }
  }

  _Thread_Change_priority(executing, 1, true);
  rtems_test_assert(node->state == SCHEDULER_SMP_NODE_SCHEDULED);

  _Thread_Enable_dispatch();

  sc = rtems_task_delete(task_id);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}
Ejemplo n.º 15
0
int select_test_main(int argc, char *argv[])
#endif
{
	int result = -1;

	if (argc < 6) {
		printf("\n[USAGE] select_test a b c d e\n");
		return 0;
	}


#ifdef ENABLE_MULTIPLE_SOCKET_TEST
	g_socket_fd = create_socket(SOCKET_TEST_PORT);
	g_socket2_fd = create_socket(SOCKET2_TEST_PORT);
#endif
	mkfifo("/dev/fifo0", 0666);
	g_file_fd = open("/dev/fifo0", O_RDWR);
	mkfifo("/dev/fifo1", 0666);
	g_fifo_wrfd = open("/dev/fifo1", O_WRONLY);
	g_fifo_rdfd = open("/dev/fifo1", O_RDONLY);
#ifdef ENABLE_PIPE_TEST
	create_pipe(g_pipe_handle);
	printf("Test Start : pipe_handle[0]=%d, pipe_handle[1]=%d\n", g_pipe_handle[0], g_pipe_handle[1]);
#endif
#ifdef ENABLE_MULTIPLE_SOCKET_TEST
	printf("Test Start :socket_fd=%d socket2_fd=%d  file_fd = %d fifo_wrfd = %d fifo_rdfd = %d \n", g_socket_fd, g_socket2_fd, g_file_fd, g_fifo_wrfd, g_fifo_rdfd);
#else
	printf("Test Start :stdin = %d file_fd = %d fifo_wrfd = %d fifo_rdfd = %d \n", 0, g_file_fd, g_fifo_wrfd, g_fifo_rdfd);
#endif

#ifdef ENABLE_SELECT_SLEEP_TEST
	struct timeval tv;
	/* Wait up to 3 seconds. */

	tv.tv_sec = 3;
	tv.tv_usec = 0;
	/* test select sleep functionality */
	select(0, NULL, NULL, NULL, &tv);
#else
	usleep(50000);
#endif

	start_task();

	{
		int param_idx = 1;

		printf("\nWriting data(%s) to g_fifo_wrfd = %d\n", argv[param_idx], g_fifo_wrfd);
		write(g_fifo_wrfd, argv[param_idx], 1);
		param_idx++;
		usleep(2000000);
#ifdef ENABLE_PIPE_TEST
		printf("\nWriting data(%s) to g_pipe_handle = %d\n", argv[param_idx], g_pipe_handle[1]);
		write_pipe(g_pipe_handle[1], argv[param_idx], 1);
		param_idx++;
		usleep(2000000);
#endif
		printf("\nWriting data(%s) to g_file_fd = %d\n", argv[param_idx], g_file_fd);
		write(g_file_fd, argv[param_idx], 1);
		param_idx++;
		usleep(2000000);
#ifdef ENABLE_MULTIPLE_SOCKET_TEST
		printf("\nWriting data(%s) to g_socket_fd = %d\n", argv[param_idx], g_socket_fd);
		write_socket(g_socket_fd, argv[param_idx], 1, SOCKET_TEST_PORT);
		param_idx++;
		usleep(2000000);
		printf("\nWriting data(%s) to g_socket2_fd = %d\n", argv[param_idx], g_socket2_fd);
		write_socket(g_socket2_fd, argv[param_idx], 1, SOCKET2_TEST_PORT);
#endif
	}

	/* success */
	result = 0;
	return result;
}
Ejemplo n.º 16
0
/**
 * @brief Dispatcher task entry point
 *
 * This task will process the smc commands and helps in creating 
 * the service tasks and calls the service task functions. \n
 * 1. On arrival of API command invocation "valid params flag" got set. 
 * Based on the flag, it process the command by invoking the appropriate task.\n
 * 2. At the completion of processing, the corresponding task sets the return
 * value of the command result in the dispatcher private data.
 * 3. Based on the result and the source, it returns to non-secure world or 
 * originated task in case of IPI.
 * 
 * @param cur_task_id - Dispatcher task identifier
 */
void dispatch_task(int cur_task_id)
{
    int ret_val;
    int svc_id, task_id, cmd_id, cmd_type;
    sw_printf("SW: dispatch task id 0x%x\n", cur_task_id);
    invoke_ns_kernel();

    while (1) {
        if(secure_interrupt_set) {
            secure_interrupt_set = 0;   
#ifdef CONFIG_EMULATE_FIQ
            emulate_timer_irq();
#endif
            return_secure_api(0);   
        }
        else if(valid_params_flag && params_stack[0] == CALL_TRUSTZONE_API) {
            valid_params_flag = 0;
            get_api_context(&svc_id, &task_id, &cmd_id, &cmd_type);

            if((svc_id == OTZ_SVC_GLOBAL) && 
            (cmd_id == OTZ_GLOBAL_CMD_ID_BOOT_ACK)) {
                if(cmd_type == OTZ_CMD_TYPE_NS_TO_SECURE) {
			tzhyp_boot_ack_event();
                }
                set_secure_api_ret(0);
            }
           else  if((svc_id == OTZ_SVC_GLOBAL) && 
            (cmd_id == OTZ_GLOBAL_CMD_ID_OPEN_SESSION)) {
                if(cmd_type == OTZ_CMD_TYPE_NS_TO_SECURE) {
/*                    sw_buddy_print_state(); */
                    ret_val = open_session_from_ns((void*)params_stack[1]);
                    if(ret_val == OTZ_ENOMEM)
                        set_secure_api_ret(SMC_ENOMEM);
                    else if(ret_val == OTZ_EFAIL)
                        set_secure_api_ret(SMC_ERROR);
                    else
                        set_secure_api_ret(0); 
                }
            }
            else if((svc_id == OTZ_SVC_GLOBAL) && 
            (cmd_id == OTZ_GLOBAL_CMD_ID_CLOSE_SESSION)) {
                if(cmd_type == OTZ_CMD_TYPE_NS_TO_SECURE) {
                    ret_val = close_session_from_ns((void*)params_stack[1]);
/*                    sw_buddy_print_state(); */
                    if(ret_val == OTZ_ENOMEM)
                        set_secure_api_ret(SMC_ENOMEM);
                    else if(ret_val == OTZ_EFAIL)
                        set_secure_api_ret(SMC_ERROR);
                    else
                        set_secure_api_ret(0);   
                }
            }
#ifdef OTZONE_ASYNC_NOTIFY_SUPPORT
            else if((svc_id == OTZ_SVC_GLOBAL) && 
            (cmd_id == OTZ_GLOBAL_CMD_ID_REGISTER_NOTIFY_MEMORY)) {
                if(cmd_type == OTZ_CMD_TYPE_NS_TO_SECURE) {
                    ret_val = register_notify_data_api((void*)params_stack[1]);
                    if(ret_val == OTZ_ENOMEM)
                        set_secure_api_ret(SMC_ENOMEM);
                    else if(ret_val == OTZ_EFAIL)
                        set_secure_api_ret(SMC_ERROR);
                    else
                        set_secure_api_ret(0);   
                }
            }
            else if((svc_id == OTZ_SVC_GLOBAL) && 
            (cmd_id == OTZ_GLOBAL_CMD_ID_UNREGISTER_NOTIFY_MEMORY)) {
                if(cmd_type == OTZ_CMD_TYPE_NS_TO_SECURE) {
                    ret_val = unregister_notify_data_api();
                    if(ret_val == OTZ_ENOMEM)
                        set_secure_api_ret(SMC_ENOMEM);
                    else if(ret_val == OTZ_EFAIL)
                        set_secure_api_ret(SMC_ERROR);
                    else
                        set_secure_api_ret(0);   
                }
            }
            else if((svc_id == OTZ_SVC_GLOBAL) && 
            (cmd_id == OTZ_GLOBAL_CMD_ID_RESUME_ASYNC_TASK)) {
                if(cmd_type == OTZ_CMD_TYPE_NS_TO_SECURE) {
                    if(task_id)
                        resume_async_task(task_id);
                }
            }
#endif
            else if(svc_id != OTZ_SVC_INVALID  && 
                task_id != 0 && 
                cmd_id != OTZ_GLOBAL_CMD_ID_INVALID) {
                start_task(task_id, params_stack);
            }
            else {
                sw_printf("SW: Invalid service id 0x%x\n", svc_id);
                set_secure_api_ret(0);
            }
        }
        schedule();
        if(g_dispatch_data->secure_api_set) {
            return_secure_api(g_dispatch_data->secure_api_ret_val);
            g_dispatch_data->secure_api_set = 0;
        }

/*        process_pending_task(); */
    }
}
Ejemplo n.º 17
0
s8int init_sound_multitsk() {
	printf ( "Initiating sound for multitasking environment." );
	start_task ( 200, 10, init_sound, 0, "init_sound_test" );
	return 0;
}