This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/17204] race condition in nice
- From: "carlos at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Thu, 03 Dec 2015 02:03:22 +0000
- Subject: [Bug libc/17204] race condition in nice
- Auto-submitted: auto-generated
- References: <bug-17204-131 at http dot sourceware dot org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=17204
Carlos O'Donell <carlos at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |SUSPENDED
CC| |carlos at redhat dot com
Severity|normal |enhancement
--- Comment #2 from Carlos O'Donell <carlos at redhat dot com> ---
(In reply to Andreas Schwab from comment #1)
> It is impossible in general to know the correct return value without calling
> getpriority.
Agreed. At best this bug is an RFC "reduce number of syscalls made in nice()
implementation."
(In reply to Steven Stewart-Gallus from comment #0)
> nice is implemented as calling getpriority and than setting the priority as
> higher and than calling getpriority again but this is racy as other tasks
> can call setpriority concurrently. This bug probably doesn't actually cause
> any problems but it could still be fixed. Fixing this bug would also reduce
> the amount of system calls by one which would be nice. Glibc should not call
> getpriority to get the new value of the priority after.
Agreed. There is a race. To fix the race would require a new kernel syscall or
some kind of userspace lock to make the priority accesses atomic. I expect the
only real solution is a `nice` syscall that does everything in one access
exclusively for the current process. Given that this is really a kernel issue
you could file two bugs, one for the kernel to implement `nice` and another for
glibc to use `nice`, but you'll have to lobby both groups to get the feature
you want and that will be difficult.
Moving to SUSPENDED until the kernel has a `nice` syscall which solves both the
race condition and reduces the implementation from 3 syscalls down to 1.
--
You are receiving this mail because:
You are on the CC list for the bug.