Kernel/LibC: Add basic support for pthread_{create,exit}
This commit is contained in:
8
userspace/tests/test-pthread/CMakeLists.txt
Normal file
8
userspace/tests/test-pthread/CMakeLists.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
set(SOURCES
|
||||
main.cpp
|
||||
)
|
||||
|
||||
add_executable(test-pthread ${SOURCES})
|
||||
banan_link_library(test-pthread libc)
|
||||
|
||||
install(TARGETS test-pthread OPTIONAL)
|
||||
28
userspace/tests/test-pthread/main.cpp
Normal file
28
userspace/tests/test-pthread/main.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void* thread_func(void*)
|
||||
{
|
||||
printf("hello from thread\n");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
pthread_t tid;
|
||||
|
||||
printf("creating thread\n");
|
||||
|
||||
if (pthread_create(&tid, nullptr, &thread_func, nullptr) == -1)
|
||||
{
|
||||
perror("pthread_create");
|
||||
return 1;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
|
||||
printf("exiting\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user