From b0dfc1d69dacb42f887a95fa596f33dea4163944 Mon Sep 17 00:00:00 2001 From: He Sun Date: Wed, 13 Nov 2019 10:41:31 +0000 Subject: [PATCH] Add epoll_pwait syscall and the test case 1. Use epoll_wait to support epoll_pwait as there is no signal mechanism 2. The timeout is fixed to zero for not waiting for any signal to come to speed up 3. Change the test case of server_epoll to use epoll_pwait --- src/libos/src/syscall/mod.rs | 19 +++++++++++++++++++ test/server_epoll/main.c | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/libos/src/syscall/mod.rs b/src/libos/src/syscall/mod.rs index 44610828..03e0ff64 100644 --- a/src/libos/src/syscall/mod.rs +++ b/src/libos/src/syscall/mod.rs @@ -135,6 +135,13 @@ pub extern "C" fn dispatch_syscall( arg2 as c_int, arg3 as c_int, ), + SYS_EPOLL_PWAIT => do_epoll_pwait( + arg0 as c_int, + arg1 as *mut libc::epoll_event, + arg2 as c_int, + arg3 as c_int, + arg4 as *const usize, //TODO:add sigset_t + ), // process SYS_EXIT => do_exit(arg0 as i32), @@ -1418,6 +1425,18 @@ fn do_epoll_wait( Ok(count as isize) } +fn do_epoll_pwait( + epfd: c_int, + events: *mut libc::epoll_event, + maxevents: c_int, + timeout: c_int, + sigmask: *const usize, //TODO:add sigset_t +) -> Result { + info!("epoll_pwait"); + //TODO:add signal support + do_epoll_wait(epfd, events, maxevents, 0) +} + fn do_uname(name: *mut utsname_t) -> Result { check_mut_ptr(name)?; let name = unsafe { &mut *name }; diff --git a/test/server_epoll/main.c b/test/server_epoll/main.c index 59b14753..eef633c3 100644 --- a/test/server_epoll/main.c +++ b/test/server_epoll/main.c @@ -89,7 +89,7 @@ main(int argc, char *argv[]) { /* The event loop */ int done_count = 0; while (done_count < proc_num) { - int n = epoll_wait(efd, events, MAXEVENTS, -1); + int n = epoll_pwait(efd, events, MAXEVENTS, -1, NULL); for (int i = 0; i < n; i++) { if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) ||