Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2938 → Rev 2939

/branches/tracing/uspace/app/debug/dthread.c
34,6 → 34,9
 
#include <stdlib.h>
#include <libadt/list.h>
#include <assert.h>
#include <futex.h>
#include <async.h>
 
#include "dthread.h"
 
53,6 → 56,8
 
dt->id = ++last_thread_id;
dt->hash = hash;
dt->fid = 0;
dt->stopped = 0;
 
if (!cwt) cwt = dt;
 
67,6 → 72,59
free(dt);
}
 
/*
* Get dthread struct serviced by fibril fid.
*/
dthread_t *dthread_get_by_fid(fid_t fid)
{
link_t *cur;
dthread_t *dt;
 
dt = NULL;
for (cur = dthreads.next; cur != &dthreads; cur = cur->next) {
dt = list_get_instance(cur, dthread_t, link);
if (dt->fid == fid) return dt;
}
 
return NULL;
}
 
/*
* Get dthread struct for dthread serviced by the current fibril.
*/
dthread_t *dthread_get(void)
{
return dthread_get_by_fid(fibril_get_id());
}
 
void dthread_stop_me(void)
{
dthread_t *dt;
int i;
 
dt = dthread_get();
assert(dt);
 
futex_down(&async_futex);
 
dt->stopped = 1;
fibril_switch(FIBRIL_TO_MANAGER);
 
futex_up(&async_futex);
}
 
void dthread_resume(dthread_t *dt)
{
if (!dt->stopped) return;
 
futex_down(&async_futex);
 
fibril_add_ready(dt->fid);
dt->stopped = 0;
 
futex_up(&async_futex);
}
 
 
/** @}
*/