コード例 #1
0
ファイル: pthread_cond.c プロジェクト: d33tah/whitix
int pthread_cond_signal(pthread_cond_t* cond)
{
	struct pthread_queue* queue;
	
	pthread_mutex_lock(&cond->mutex);
	queue = cond->list;
	
	if (cond->list)
		cond->list = cond->list->next;
		
	pthread_mutex_unlock(&cond->mutex);	

	/* Wake up the first in the queue. */
	if (queue)
	{
		cond->signal = PTHREAD_COND_SIGNAL;
		SysResumeThread(queue->threadId);
	}

	return 0;
}
コード例 #2
0
ファイル: pthread_cond.c プロジェクト: d33tah/whitix
int pthread_cond_broadcast(pthread_cond_t* cond)
{
	struct pthread_queue* queue;
	
	pthread_mutex_lock(&cond->mutex);
	
	queue = cond->list;
	cond->list = NULL;

	pthread_mutex_unlock(&cond->mutex);

	if (queue)
		cond->signal = PTHREAD_COND_SIGNAL;

	while (queue)
	{
		int threadId = queue->threadId;
		SysResumeThread(threadId);
		queue = queue->next;
	}

	return 0;
}
コード例 #3
0
ファイル: pthread.c プロジェクト: d33tah/whitix
static void pthread_start(void* arg)
{
	struct pthreadArgs* pArgs=(struct pthreadArgs*)arg;
	void* (*start)(void*) = pArgs->startRoutine;
	void* args = pArgs->args;
	
	struct pthread_queue entry;
	struct pthread_queue* head;

	DlTlsCreateContext();
	
	entry.threadId = pGetCurrentThreadId();
	entry.next = NULL;
	
	pthread_mutex_lock(&listMutex);
	
	head = threadList;
	
	while (head->next)
		head = head->next;
		
	head->next = &entry;
	
	pthread_mutex_unlock(&listMutex);

	pthread_cond_signal(pArgs->signal);

	start(args);
	
	/* Remove ourselves from the thread list. */
	pthread_mutex_lock(&listMutex);
	
	head = threadList;
	
	while (head->next && head->next != &entry)
		head = head->next;
	
	if (head->next)
		head->next = head->next->next;
		
	pthread_mutex_unlock(&listMutex);

	/* Wake up and remove everything in the join list. */
	pthread_mutex_lock(&joinMutex);
	
	head = joinList;
	joinList = NULL;
	
	while (head)
	{
		SysResumeThread(head->threadId);
		
		head = head->next;
	}
	
	pthread_mutex_unlock(&joinMutex);
	
	/* Actually exit the thread. We used to be able to return onto a frame
	 * set up by the kernel, but that no longer happens. */
	SysExitThread(-1);
}
コード例 #4
0
ファイル: wprocess.cpp プロジェクト: Ga-vin/sgos
void Thread::Resume()
{
	if( this->threadId > 0 )
		SysResumeThread( this->threadId );
}
コード例 #5
0
ファイル: device.cpp プロジェクト: Ga-vin/sgos
void device_startService()
{
	SysResumeThread(deviceThread);
}