创建线程库

master
p9ya4sf57 2 years ago
parent f9002a0d39
commit 771f55af9f

@ -0,0 +1,53 @@
#include "pthread.h"
_syscall2(int, create_thread, unsigned long, start, void*, arg);
_syscall2(int, syspthread_join, pthread_t, thread, void*, value_ptr);
_syscall1(int, endthread, int, value);
int pthread_attr_init(pthread_attr_t* attr)
{
;;;;;
return 0;
}
int pthread_create(pthread_t* thread, const pthread_attr_t* attr, void* (*start)(void*), void* arg)
{
int id = 0;
if (!thread) return EINVAL;
id = create_thread((unsigned long)start, (int*)arg);
if (id < 0) return errno;
*thread = id;
return id;
}
void pthread_exit(void* value_ptr)
{
endthread((int)value_ptr);
}
int pthread_join(pthread_t thread, void** value_ptr)
{
syspthread_join(thread, value_ptr);
return 0;
}
Loading…
Cancel
Save