case THREAD_CREATE: {
thrd_t *thrd = (thrd_t *)curr->get_location();
struct thread_params *params = (struct thread_params *)curr->get_value();
- Thread *th = new Thread(thrd, params->func, params->arg);
+ Thread *th = new Thread(thrd, params->func, params->arg, get_thread(curr));
add_thread(th);
th->set_creation(curr);
/* Promises can be satisfied by children */
{
ASSERT(t && !t->is_model_thread());
- // curr_thread_index = id_to_int(t->get_id());
+ //curr_thread_index = id_to_int(t->get_id());
current = t;
if (DBG_ENABLED())
class Thread {
public:
Thread(thread_id_t tid);
- Thread(thrd_t *t, void (*func)(void *), void *a);
+ Thread(thrd_t *t, void (*func)(void *), void *a, Thread * parent_thrd = NULL);
~Thread();
void complete();
* @param func The function that the thread will call.
* @param a The parameter to pass to this function.
*/
-Thread::Thread(thrd_t *t, void (*func)(void *), void *a) :
+Thread::Thread(thrd_t *t, void (*func)(void *), void *a, Thread * parent_thrd) :
creation(NULL),
pending(NULL),
start_routine(func),
id = model->get_next_id();
user_thread->priv = this;
- parent = thread_current();
+ parent = parent_thrd ? parent_thrd : thread_current();
}
/** Destructor */