progress on setting up host/client api process execution

This commit is contained in:
2025-10-12 19:52:17 -04:00
parent 406ff97968
commit 8ced7cc71e
7 changed files with 54 additions and 42 deletions

View File

@@ -28,29 +28,23 @@ startup :: proc(host_mem: ^HostMemory, thread_mem: ^ThreadMemory)
memory = host_mem
thread_wide_startup()
thread_wide_startup(thread_mem)
}
thread_wide_startup :: proc()
thread_wide_startup :: proc(thread_mem: ^ThreadMemory)
{
if thread_memory.id == .Master_Prepper
{
thread_memory.live_lanes =
tick_lane_startup() //
if thread_mem.id == .Master_Prepper {
sync.barrier_init(& memory.client_api_sync_lock, THREAD_TICK_LANES)
}
// TODO(Ed): Spawn helper thraed, then prepp both live threads
memory.state.live_threads += 1; // Atomic_Accountant
memory.host_api.launch_live_thread()
memory.host_api.launch_tick_lane_thread(.Atomic_Accountant)
tick_lane_startup(thread_mem)
}
@export
tick_lane_startup :: proc(thread_mem: ^ThreadMemory)
{
memory.state.live_threads += 1
thread_memory = thread_mem
thread_memory.live_lanes = THREAD_TICK_LANES
tick_lane()
}
@@ -60,11 +54,11 @@ tick_lane :: proc()
for ;;
{
dummy += 1
if thread_memory.index == .Master_Prepper
if thread_memory.id == .Master_Prepper
{
memory.host_api.sync_client_api()
memory.host_api.sync_client_module()
}
leader := sync.barrier_wait(& memory.client_api_sync_lock)
}
}

View File

@@ -5,15 +5,17 @@ import "core:sync"
HostMemory :: struct {
host_scratch: [256 * Kilo]byte,
client_api_sync_lock: sync.Benaphore,
threads: [MAX_THREADS](SysThread),
client_api: ModuleAPI,
client_memory: ^State,
host_api: Host_API,
client_api_sync_lock: sync.Barrier,
client_api: ModuleAPI,
client_memory: State,
host_api: Host_API,
}
Host_API :: struct {
launch_live_thread: #type proc(),
launch_tick_lane_thread: #type proc(WorkerID),
request_virtual_memory: #type proc(),
request_virtual_mapped_io: #type proc(),

View File

@@ -41,7 +41,7 @@ JobSystemContext :: struct {
}
ThreadWorkerContext :: struct {
system_ctx: Thread,
system_ctx: ^SysThread,
id: WorkerID,
}
@@ -189,7 +189,7 @@ WorkerID :: enum int {
}
// Hard constraint for Windows
JOB_SYSTEM_MAX_WORKER_THREADS :: 64
MAX_THREADS :: 64
/*
Threads are setup upfront during the client API's startup.

View File

@@ -4,7 +4,7 @@ import "core:sync"
AtomicMutex :: sync.Atomic_Mutex
import "core:thread"
Thread :: thread.Thread
SysThread :: thread.Thread
Kilo :: 1024
Mega :: Kilo * 1024

View File

@@ -9,6 +9,5 @@ thread_memory: ^ThreadMemory
THREAD_TICK_LANES :: 2
State :: struct {
live_threads: int,
job_system: JobSystemContext,
}