mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-18 20:36:31 +00:00
🆕 clock()函数
This commit is contained in:
@ -36,3 +36,10 @@ struct timespec
|
||||
* @return int
|
||||
*/
|
||||
extern int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
|
||||
|
||||
/**
|
||||
* @brief 获取当前的CPU时间
|
||||
*
|
||||
* @return uint64_t timer_jiffies
|
||||
*/
|
||||
extern uint64_t clock();
|
@ -16,6 +16,7 @@
|
||||
extern void system_call(void);
|
||||
extern void syscall_int(void);
|
||||
|
||||
extern uint64_t sys_clock(struct pt_regs* regs);
|
||||
|
||||
|
||||
/**
|
||||
@ -770,5 +771,6 @@ system_call_t system_call_table[MAX_SYSTEM_CALL_NUM] =
|
||||
[16] = sys_exit,
|
||||
[17] = sys_mkdir,
|
||||
[18] = sys_nanosleep,
|
||||
[19 ... 254] = system_call_not_exists,
|
||||
[19] = sys_clock,
|
||||
[20 ... 254] = system_call_not_exists,
|
||||
[255] = sys_ahci_end_req};
|
||||
|
@ -29,5 +29,6 @@
|
||||
#define SYS_EXIT 16 // 进程退出
|
||||
#define SYS_MKDIR 17 // 创建文件夹
|
||||
#define SYS_NANOSLEEP 18 // 纳秒级休眠
|
||||
#define SYS_CLOCK 19 // 获取当前cpu时间
|
||||
|
||||
#define SYS_AHCI_END_REQ 255 // AHCI DMA请求结束end_request的系统调用
|
@ -106,3 +106,13 @@ void timer_func_del(struct timer_func_list_t *timer_func)
|
||||
{
|
||||
list_del(&timer_func->list);
|
||||
}
|
||||
|
||||
uint64_t sys_clock(struct pt_regs *regs)
|
||||
{
|
||||
return timer_jiffies;
|
||||
}
|
||||
|
||||
uint64_t clock()
|
||||
{
|
||||
return timer_jiffies;
|
||||
}
|
||||
|
@ -61,3 +61,6 @@ void timer_func_add(struct timer_func_list_t *timer_func);
|
||||
* @param timer_func
|
||||
*/
|
||||
void timer_func_del(struct timer_func_list_t *timer_func);
|
||||
|
||||
|
||||
uint64_t clock();
|
||||
|
@ -432,7 +432,7 @@ int shell_cmd_exec(int argc, char **argv)
|
||||
// printf("parent process wait for pid:[ %d ]\n", pid);
|
||||
|
||||
waitpid(pid, &retval, 0);
|
||||
printf("parent process wait pid [ %d ], exit code=%d\n", pid, retval);
|
||||
// printf("parent process wait pid [ %d ], exit code=%d\n", pid, retval);
|
||||
free(argv);
|
||||
}
|
||||
}
|
||||
|
@ -30,3 +30,13 @@ int usleep(useconds_t usec)
|
||||
|
||||
return nanosleep(&ts, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 获取系统当前cpu时间
|
||||
*
|
||||
* @return clock_t
|
||||
*/
|
||||
clock_t clock()
|
||||
{
|
||||
return (clock_t)syscall_invoke(SYS_CLOCK, 0,0,0,0,0,0,0,0);
|
||||
}
|
@ -36,3 +36,10 @@ struct timespec
|
||||
* @return int
|
||||
*/
|
||||
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
|
||||
|
||||
/**
|
||||
* @brief 获取系统当前cpu时间
|
||||
*
|
||||
* @return clock_t
|
||||
*/
|
||||
clock_t clock();
|
@ -23,6 +23,7 @@
|
||||
#define SYS_EXIT 16 // 进程退出
|
||||
#define SYS_MKDIR 17 // 创建文件夹
|
||||
#define SYS_NANOSLEEP 18 // 纳秒级休眠
|
||||
#define SYS_CLOCK 19 // 获取当前cpu时间
|
||||
|
||||
/**
|
||||
* @brief 用户态系统调用函数
|
||||
|
Reference in New Issue
Block a user