Exemplo n.º 1
0
static inline void fdtask_shutdown()
{
    int i = 0;

    for(i = 0; i < SuperPoll_active_hot(POLL); i++) {
        SuperPoll_compact_down(POLL, i);
    }

    // move all our sleeping tasks over to the main runqueue
    Task *t = NULL;
    while((t = sleeping.head)){
        deltask(&sleeping, t);
        tasksignal(t, task_was_signaled());
    }
}
Exemplo n.º 2
0
int tasknuke(int id)
{
    int i = 0;
    Task *target = NULL;

    for(i = 0; i < SuperPoll_active_hot(POLL); i++) {
        target = (Task *)SuperPoll_data(POLL, i);

        if(target && target->id == id) {
            SuperPoll_compact_down(POLL, i);
            return 0;
        }
    }

    return -1;
}
Exemplo n.º 3
0
void
fdtask(void *v)
{
    int i, ms;
    PollResult result;
    int rc = 0;
    
    rc = PollResult_init(POLL, &result);
    check(rc == 0, "Failed to initialize the poll result.");

    tasksystem();
    taskname("fdtask");

    for(;;){
        /* let everyone else run */
        while(taskyield() > 0)
            ;
        /* we're the only one runnable - poll for i/o */
        errno = 0;
        taskstate("poll");

        ms = next_task_sleeptime(500);

        if(SIGNALED) {
            for(i = 0; i < SuperPoll_active_hot(POLL); i++) {
                Task *target = (Task *)SuperPoll_data(POLL, i);
                if(target) taskready(target);
                SuperPoll_compact_down(POLL, i);
            }
        } else {
            rc = SuperPoll_poll(POLL, &result, ms);
            check(rc != -1, "SuperPoll failure, aborting.");

            for(i = 0; i < rc; i++) {
                taskready(result.hits[i].data); 
            }
        }

        wake_sleepers();
    }

    PollResult_clean(&result);
    taskexit(0);

error:
    taskexitall(1);
}