mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-18 08:06:32 +00:00
修复jiffy时钟过快问题,启用gettimeofday测试,修改mount测试 (#680)
1. 把clock tick rate与hpet频率关联起来 2. 修复墙上时间同步错误的问题 3. 启用时间watch dog. 4. 修复时间流逝速度异常 --------- Co-authored-by: longjin <longjin@DragonOS.org>
This commit is contained in:
@ -1,7 +1,14 @@
|
||||
use core::ffi::{c_char, c_void};
|
||||
use libc::{mount, MS_BIND};
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use std::time;
|
||||
fn main() {
|
||||
let path = Path::new("mnt/tmp");
|
||||
let dir = fs::create_dir_all(path);
|
||||
if dir.is_err() {
|
||||
panic!("mkdir /mnt/tmp fail.");
|
||||
}
|
||||
let clock = time::Instant::now();
|
||||
let source = b"\0".as_ptr() as *const c_char;
|
||||
let target = b"/mnt/tmp\0".as_ptr() as *const c_char;
|
||||
@ -9,7 +16,13 @@ fn main() {
|
||||
let flags = MS_BIND;
|
||||
let data = std::ptr::null() as *const c_void;
|
||||
let result = unsafe { mount(source, target, fstype, flags, data) };
|
||||
|
||||
let path = Path::new("mnt/tmp/tmp");
|
||||
let dir = fs::create_dir_all(path);
|
||||
if dir.is_err() {
|
||||
panic!("mkdir /mnt/tmp/tmp fail.");
|
||||
}
|
||||
let target = b"/mnt/tmp/tmp\0".as_ptr() as *const c_char;
|
||||
let result = unsafe { mount(source, target, fstype, flags, data) };
|
||||
if result == 0 {
|
||||
println!("Mount successful");
|
||||
} else {
|
||||
|
@ -8,16 +8,16 @@
|
||||
int main()
|
||||
{
|
||||
struct timeval *tv = malloc(sizeof(struct timeval));
|
||||
// struct timezone *tz = malloc(sizeof(struct timezone));
|
||||
// for (int i = 0; i < 15; i++)
|
||||
// {
|
||||
// gettimeofday(tv, NULL);
|
||||
// printf("%ld.%06ld\n", tv->tv_sec, tv->tv_usec);
|
||||
// for (int i = 0; i < 10; i++)
|
||||
// {
|
||||
// usleep(500000);
|
||||
// }
|
||||
// }
|
||||
struct timezone *tz = malloc(sizeof(struct timezone));
|
||||
for (int i = 0; i < 15; i++)
|
||||
{
|
||||
gettimeofday(tv, NULL);
|
||||
printf("%ld.%06ld\n", tv->tv_sec, tv->tv_usec);
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
usleep(500000);
|
||||
}
|
||||
}
|
||||
gettimeofday(tv, NULL);
|
||||
printf("tv = %ld.%06ld\n", tv->tv_sec, tv->tv_usec);
|
||||
// printf("tz_minuteswest = %d,tz_dsttime = %d", (*tz).tz_minuteswest, (*tz).tz_dsttime);
|
||||
|
Reference in New Issue
Block a user