🆕 usleep()、nanosleep()

This commit is contained in:
fslongjin
2022-07-12 12:01:51 +08:00
parent 4208c56074
commit 676260c537
21 changed files with 277 additions and 15 deletions

View File

@ -10,11 +10,14 @@
#include <filesystem/VFS/VFS.h>
#include <driver/keyboard/ps2_keyboard.h>
#include <process/process.h>
#include <time/sleep.h>
// 导出系统调用入口函数定义在entry.S中
extern void system_call(void);
extern void syscall_int(void);
/**
* @brief 导出系统调用处理函数的符号
*
@ -723,6 +726,15 @@ uint64_t sys_exit(struct pt_regs *regs)
return process_do_exit(regs->r8);
}
uint64_t sys_nanosleep(struct pt_regs * regs)
{
const struct timespec * rqtp = (const struct timespec*)regs->r8;
struct timespec * rmtp = (struct timespec*)regs->r9;
return nanosleep(rqtp, rmtp);
}
ul sys_ahci_end_req(struct pt_regs *regs)
{
ahci_end_request();
@ -757,5 +769,6 @@ system_call_t system_call_table[MAX_SYSTEM_CALL_NUM] =
[15] = sys_wait4,
[16] = sys_exit,
[17] = sys_mkdir,
[18 ... 254] = system_call_not_exists,
[18] = sys_nanosleep,
[19 ... 254] = system_call_not_exists,
[255] = sys_ahci_end_req};

View File

@ -28,5 +28,6 @@
#define SYS_WAIT4 15 // 等待进程退出
#define SYS_EXIT 16 // 进程退出
#define SYS_MKDIR 17 // 创建文件夹
#define SYS_NANOSLEEP 18 // 纳秒级休眠
#define SYS_AHCI_END_REQ 255 // AHCI DMA请求结束end_request的系统调用