Exemplo n.º 1
0
Arquivo: main.c Projeto: wuwx/simba
int test_preemptive(struct harness_t *harness_p)
{
    struct time_t timeout;
    struct time_t start, stop, duration;

    /* Spawn a low priority worker thread. */
    BTASSERT(thrd_spawn(preemptive_main,
                        NULL,
                        20,
                        preemptive_stack,
                        sizeof(preemptive_stack)) != NULL);

    BTASSERT(time_get(&start) == 0);

    /* Suspend this thread to make sure the worker thread is in its
       infinite loop. When the suspend timeout occurs, this thread
       will be scheduled since it has higher priority than the worker
       thread. */
    timeout.seconds = 0;
    timeout.nanoseconds = 10000000;
    BTASSERT(thrd_suspend(&timeout) == -ETIMEDOUT);

    BTASSERT(time_get(&stop) == 0);
    BTASSERT(time_subtract(&duration, &stop, &start) == 0);

    BTASSERT(duration.seconds == 0);
    BTASSERTI(duration.nanoseconds, >=, 10000000);

    return (0);
}
Exemplo n.º 2
0
Arquivo: main.c Projeto: eerimoq/simba
int main()
{
    init();

    thrd_suspend(NULL);
    
    return (0);
}
Exemplo n.º 3
0
/**
 * Call given callback from the LwIP thread.
 */
static int tcpip_call_output(struct socket_t *self_p,
                             void (*callback)(void *ctx_p),
                             void *args_p)
{
    self_p->output.cb.args_p = args_p;
    self_p->output.cb.thrd_p = thrd_self();

    tcpip_callback_with_block(callback, self_p, 0);

    return (thrd_suspend(NULL));
}
Exemplo n.º 4
0
Arquivo: main.c Projeto: wuwx/simba
int test_suspend_resume(struct harness_t *harness_p)
{
    int err;
    struct thrd_t *thrd_p;

    thrd_p = thrd_spawn(suspend_resume_main,
                        thrd_self(),
                        10,
                        suspend_resume_stack,
                        sizeof(suspend_resume_stack));

    err = thrd_suspend(NULL);
    BTASSERT(err == 3);

    /* Wait for the spawned thread to terminate, twice. */
    BTASSERT(thrd_join(thrd_p) == 0);
    BTASSERT(thrd_join(thrd_p) == 0);

    return (0);
}