wip: IPC and Runtime
This commit is contained in:
@@ -69,6 +69,7 @@ OSTask* SchedulerSpawn(void(*entryPoint)(), OSProcess* owner, Boolean isUser, Ad
|
||||
task->waitingForProcessId = -1;
|
||||
|
||||
task->next = gOSSchedulerCurrentTask->next;
|
||||
task->senderWaiting = nullptr;
|
||||
gOSSchedulerCurrentTask->next = task;
|
||||
|
||||
return task;
|
||||
@@ -126,3 +127,30 @@ void SchedulerYield(UInt64 ticks) {
|
||||
UInt64 SchedulerGetNextProcessID() {
|
||||
return gOSSchedulerNextProcessID++;
|
||||
}
|
||||
|
||||
void SchedulerBlockCurrentTask(UInt32 newState) {
|
||||
gOSSchedulerCurrentTask->state = newState;
|
||||
CPUException(kOSSchedulerExceptionNumber);
|
||||
}
|
||||
|
||||
OSTask* SchedulerGetCurrentTask() {
|
||||
return gOSSchedulerCurrentTask;
|
||||
}
|
||||
|
||||
Int32 SchedulerProcessAllocateHandle(OSProcess* process, OSHandleType type, Pointer object) {
|
||||
for (Int32 i = 1; i < kOSMaxHandlesPerProcess; i++) {
|
||||
if (process->handles[i].type == kOSHandleTypeNone) {
|
||||
process->handles[i].type = type;
|
||||
process->handles[i].object = object;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
Pointer SchedulerProcessGetHandle(OSProcess* process, UInt32 handleId, OSHandleType expectedType) {
|
||||
if (handleId == 0 || handleId >= kOSMaxHandlesPerProcess) return nullptr;
|
||||
OSHandle* handle = &process->handles[handleId];
|
||||
if (handle->type != expectedType) return nullptr;
|
||||
return handle->object;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user