progress on setting up host/client api process execution
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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(),
|
||||
|
@@ -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.
|
||||
|
Reference in New Issue
Block a user