bootstrap: test pthread features

This commit is contained in:
2026-03-18 21:10:18 +00:00
parent 863be171c1
commit 844f6d50eb
2 changed files with 19 additions and 1 deletions

View File

@@ -6,7 +6,7 @@ set_property(SOURCE ${arch_sources} PROPERTY LANGUAGE C)
add_executable(bootstrap ${c_sources} ${arch_sources}) add_executable(bootstrap ${c_sources} ${arch_sources})
target_link_libraries(bootstrap target_link_libraries(bootstrap
libmango libc-core libc-malloc libfs-static liblaunch libxpc-static libmango libc-core libc-malloc libc-pthread libfs-static liblaunch libxpc-static
interface::fs) interface::fs)
target_compile_options(bootstrap PRIVATE target_compile_options(bootstrap PRIVATE

View File

@@ -7,10 +7,12 @@
#include <fs/context.h> #include <fs/context.h>
#include <heap/heap.h> #include <heap/heap.h>
#include <launch.h> #include <launch.h>
#include <mango/handle.h>
#include <mango/log.h> #include <mango/log.h>
#include <mango/msg.h> #include <mango/msg.h>
#include <mango/task.h> #include <mango/task.h>
#include <mango/types.h> #include <mango/types.h>
#include <pthread.h>
#include <rosetta/bootstrap.h> #include <rosetta/bootstrap.h>
#include <rosetta/fs.h> #include <rosetta/fs.h>
#include <stdint.h> #include <stdint.h>
@@ -90,6 +92,13 @@ static void _fs_free(struct fs_allocator *alloc, void *p)
heap_free(alloc->fs_arg, p); heap_free(alloc->fs_arg, p);
} }
void *thread_func(void *arg)
{
kern_logf("a thread! (%p)", pthread_self());
// kern_logf("a thread!");
return (void *)0x123;
}
int main( int main(
int argc, int argc,
const char **argv, const char **argv,
@@ -159,6 +168,11 @@ int main(
kern_handle_t channel; kern_handle_t channel;
channel_create(0, &channel); channel_create(0, &channel);
pthread_t thread;
pthread_create(&thread, NULL, thread_func, NULL);
pthread_detach(thread);
kern_logf("created new thread %p", thread);
launch_ctx_init(&launch); launch_ctx_init(&launch);
launch.ctx_resolve_library = resolve_dependency; launch.ctx_resolve_library = resolve_dependency;
@@ -169,6 +183,10 @@ int main(
return -1; return -1;
} }
kern_handle_close(result.r_task);
kern_handle_close(result.r_thread);
kern_handle_close(result.r_address_space);
heap_t heap = HEAP_INIT; heap_t heap = HEAP_INIT;
struct fs_allocator fs_allocator = { struct fs_allocator fs_allocator = {