Example #1
0
void fdtask(void *v)
{
    int i, ms;
    PollResult result;
    int rc = 0;
    FDTASK = taskself();
    
    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(task_was_signaled()) {
            fdtask_shutdown();
            task_clear_signal();
            break;
        } 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);
    FDTASK = NULL;
    return;

error:
    taskexitall(1);
}
Example #2
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);
}