os/libc/tasking.c
2020-08-02 14:37:23 -05:00

54 lines
1.1 KiB
C

#include <sys/syscalls.h>
#include <sys/types.h>
#include <tasking.h>
#define QUAUX(X) #X
#define QU(X) QUAUX(X)
void yield() {
asm volatile(" \
mov $" QU(SYSCALL_YIELD) ", %%eax; \
int $80; \
"::"b"(0));
}
void create_proc(void* start,void* address_space,void* param1,void* param2) {
asm volatile(" \
mov $" QU(SYSCALL_CREATEPROC) ", %%eax; \
int $80; \
"::"b"(start),"c"(address_space),"d"(param1),"S"(param2));
}
__attribute__((noreturn)) void exit(int code) {
code=code&0xff;
asm volatile(" \
mov $" QU(SYSCALL_EXIT) ", %%eax; \
int $80; \
"::"b"(code));
for(;;);
}
void block_thread(thread_state state) {
asm volatile(" \
mov $" QU(SYSCALL_BLOCK) ", %%eax; \
int $80; \
"::"b"(state));
}
void unblock_thread(pid_t pid,pid_t tid) {
asm volatile(" \
mov $" QU(SYSCALL_UNBLOCK) ", %%eax; \
int $80; \
"::"b"(pid),"c"(tid));
}
char check_proc_exists(pid_t pid) {
char exists;
asm volatile(" \
mov $" QU(SYSCALL_CHECK_PROC_EXISTS) ", %%eax; \
int $80; \
":"=c"(exists):"b"(pid));
return exists;
}