mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-10 20:36:48 +00:00
内核态usleep
This commit is contained in:
parent
16d6b94c46
commit
e7fb6df203
@ -37,6 +37,14 @@ struct timespec
|
||||
*/
|
||||
extern int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
|
||||
|
||||
/**
|
||||
* @brief 睡眠指定时间
|
||||
*
|
||||
* @param usec 微秒
|
||||
* @return int
|
||||
*/
|
||||
extern int usleep(useconds_t usec);
|
||||
|
||||
/**
|
||||
* @brief 获取当前的CPU时间
|
||||
*
|
||||
|
@ -59,4 +59,20 @@ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 睡眠指定时间
|
||||
*
|
||||
* @param usec 微秒
|
||||
* @return int
|
||||
*/
|
||||
int usleep(useconds_t usec)
|
||||
{
|
||||
struct timespec ts = {
|
||||
tv_sec : (long int)(usec / 1000000),
|
||||
tv_nsec : (long int)(usec % 1000000) * 1000UL
|
||||
};
|
||||
|
||||
return nanosleep(&ts, NULL);
|
||||
}
|
||||
|
@ -14,3 +14,10 @@
|
||||
*/
|
||||
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
|
||||
|
||||
/**
|
||||
* @brief 睡眠指定时间
|
||||
*
|
||||
* @param usec 微秒
|
||||
* @return int
|
||||
*/
|
||||
int usleep(useconds_t usec);
|
Loading…
x
Reference in New Issue
Block a user