Example #1
0
static void deferred_refdec_init(void)
{
    hal_mutex_init( &deferred_refdec_mutex, "refdec");

    hal_cond_init(  &start_refdec_cond, "refdec st" );
    hal_cond_init(  &end_refdec_cond, "refdec end" );

    deferred_refdec_thread_id = hal_start_thread( deferred_refdec_thread, 0, 0 );
    assert(deferred_refdec_thread_id > 0 );

    inited = 1;
}
Example #2
0
static void start_new_vm_thread(struct pvm_object new_thread)
{
    args_used++;

    //int tid = hal_start_thread(thread_run_func, &new_thread, THREAD_FLAG_VM|THREAD_FLAG_USER);
    int tid = hal_start_thread(thread_run_func, &new_thread, THREAD_FLAG_VM);

    struct data_area_4_thread *tda = pvm_object_da( new_thread, thread );
    tda->tid = tid;

    t_set_owner( tid, new_thread.data );
    //phantom_thread_t *t = get_thread(tid);
    //t->owner = new_thread.data;

    while(args_used > 0)
        hal_sleep_msec(1);

    if(tda->sleep_flag)
    {
        //timedcall_t *e = &(tda->timer);
        net_timer_event *e = &(tda->timer);

        int didit = 0;

        if( e->pending )
        {
            bigtime_t msecMore = e->sched_time - hal_system_time();

            msecMore /= 1000;

            if( msecMore > 0 )
            {
                // Thread is sleeping on timer, reactivate wakeup
                phantom_wakeup_after_msec( msecMore, tda );
            }
            else
            {
                // Sleep time is passed, just wake
                SYSCALL_WAKE_THREAD_UP(tda);
            }
            didit = 1;
        }

        if(!didit)
        {
            SHOW_ERROR( 0, "Sleeping VM thread has no means to wakeup (%p)", new_thread.data );
        }

    }
}
static void start_paint_thread(void)
{
    hal_sem_init( &paint_sem, "paint" );
    paint_tid = hal_start_thread( paint_thread, 0, 0 );
}