On Tue, 23 Feb 2021 23:11:43 +0800 Eric Gao <eric.tech@xxxxxxxxxxx> wrote:
sometimes, we need the msgsnd or msgrcv syscall can return after a limitedPlease cc Manfred and Davidlohr on ipc/ changes.
time, so that the business thread do not be blocked here all the time. In
this case, I add the msgsnd_timed and msgrcv_timed syscall that with time
parameter, which has a unit of ms.
The above is a very brief description for a new syscall! Please go to
great lengths to tell us why this is considered useful - what are the
use cases?
Also, please fully describe the proposed syscall interface right here
in the changelog. Please be prepared to later prepare a full manpage.
...Specifying the timeout in milliseconds is problematic - it's very
+SYSCALL_DEFINE5(msgsnd_timed, int, msqid, struct msgbuf __user *, msgp, size_t, msgsz,
+ int, msgflg, long, timeoutms)
coarse. See sys_epoll_pwait2()'s use of timespecs.
> - schedule();No. schedule_timeout_interruptible() just means that __set_current_state() is called before the schedule_timeout().
> +
> + /* sometimes, we need msgsnd syscall return after a given time */
> + if (timeoutms <= 0) {
> + schedule();
> + } else {
> + timeoutms = schedule_timeout(timeoutms);
> + if (timeoutms == 0)
> + timeoutflag = true;
> + }
I wonder if this should be schedule_timeout_interruptible() or at least
schedule_timeout_killable() instead of schedule_timeout(). If it should,
this should probably be done as a separate change.