Beispiel #1
0
STATUS taskGetInfo(TASK_ID task_id, TASK_DESC *desc)
{
	int vfirst, vlast, ret;
	struct wind_task *task;
	struct WIND_TCB *tcb;
	pthread_attr_t attr;
	size_t stacksize;
	void *stackbase;

	task = get_wind_task(task_id);
	if (task == NULL) {
		errno = S_objLib_OBJ_ID_ERROR;
		return ERROR;
	}

	tcb = task->tcb;
	desc->td_tid = task_id;
	desc->td_priority = wind_task_get_priority(task);
	desc->td_status = get_task_status(task);
	desc->td_flags = tcb->flags;
	strncpy(desc->td_name, task->name, sizeof(desc->td_name));
	desc->td_entry = tcb->entry;
	desc->td_errorStatus = *task->thobj.errno_pointer;
	ret = pthread_getattr_np(task->thobj.tid, &attr);
	put_wind_task(task);

	/*
	 * If the target does not support pthread_getattr_np(), we are
	 * out of luck for determining the stack information. We just
	 * zero it.
	 */
	if (ret) {
		/* No idea, buddy. */
		desc->td_stacksize = 0;
		desc->td_pStackBase = NULL;
	} else {
		pthread_attr_getstack(&attr, &stackbase, &stacksize);
		desc->td_stacksize = stacksize;
		desc->td_pStackBase = stackbase;

		if (&vfirst < &vlast)
			/* Stack grows upward. */
			desc->td_pStackEnd = (caddr_t)stackbase + stacksize;
		else
			/* Stack grows downward. */
			desc->td_pStackEnd = (caddr_t)stackbase - stacksize;
	}

	return OK;
}
Beispiel #2
0
BOOL taskIsReady(TASK_ID task_id)
{
	struct wind_task *task;
	int status;

	task = get_wind_task(task_id);
	if (task == NULL)
		return 0;

	status = get_task_status(task);
	put_wind_task(task);

	return status == WIND_READY;
}
Beispiel #3
0
BOOL taskIsSuspended(TASK_ID task_id)
{
	struct wind_task *task;
	int status;

	task = get_wind_task(task_id);
	if (task == NULL)
		return 0;

	status = threadobj_get_status(&task->thobj);

	put_wind_task(task);

	return (status & __THREAD_S_SUSPENDED) != 0;
}
Beispiel #4
0
struct wind_task *get_wind_task_or_self(TASK_ID tid)
{
	struct wind_task *current;

	if (tid)
		return get_wind_task(tid);

	current = wind_task_current();
	if (current == NULL)
		return NULL;

	/* This one might block but can't fail, it is ours. */
	threadobj_lock(&current->thobj);

	return current;
}