haiku/headers/private/libroot
Timothy Gu 8ae2e95643 libroot: add [gs]etpriority implementation
Implemented against POSIX-1.2013.

The implementation POSIX requirement thats setpriority() shall affect the
priority of all system scope threads only extends to POSIX threads. This
is implemented by modifying the default attributes for newly spawned
pthreads.

It is not possible to modify the default pthread attributes for different
processes with the current implementation, as default pthread attributes
are implemented in user-space. As a result, PRIO_PROCESS for which and 0
for who is the only supported combination for setpriority().

While it is possible to move the default attributes to the kernel, it
is chosen not to so as to keep the pthread implementation user-space only.

POSIX requires that lowering the nice value (increasing priority) can be
done only by processes with appropriate privileges. However, as Haiku
currently doesn't harbor any restrictions in setting the thread priority,
this is not implemented.

It is possible to have small precision errors when converting from Unix-
style thread priority to Be-style. For example, the following program
outputs "17" instead of the expected "18":

	#include <stdio.h>
	#include <sys/resource.h>

	int
	main()
	{
		setpriority(PRIO_PROCESS, 0, 18);
		printf("%d\n", getpriority(PRIO_PROCESS, 0));
		return 0;
	}

The underlying reason is because when you setpriority() both 18 and 19
are converted to the Be-style "2". This problem should not happen with
priority levels lower than or equal to 20, when the Be notation is more
precise than the Unix-style.

Done as a part of GCI 2014. Fixes #2817.

Signed-off-by: Timothy Gu <timothygu99@gmail.com>
Co-authored-by: Leorize <leorize+oss@disroot.org>
Change-Id: Ie14f105b00fe8563d16b3562748e1c2e56c873a6
Reviewed-on: https://review.haiku-os.org/c/78
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
2019-01-19 18:31:58 +00:00
..
locale ICU locale backend: Increase size of fLocaleDescription from 512 to 1024 bytes. 2018-05-19 20:44:51 -04:00
time
dirent_private.h
errno_private.h Introduce __set_errno() throughout libroot. 2011-11-24 23:48:18 +01:00
ErrnoMaintainer.h Let ErrnoMaintainer restore errno unconditionally. 2011-11-24 23:48:18 +01:00
extended_system_info.h
fork.h
image_private.h
launch.h libroot: added ability to communicate with the launch_daemon. 2015-07-22 20:40:42 +02:00
libroot_lock.h
libroot_private.h libroot: Introduce thread specific heap init/exit hooks. 2018-12-25 23:00:20 +00:00
mathimpl.h
memory_private.h Add private get_memory_properties() syscall which allows one to retrieve the 2011-06-12 20:17:14 +00:00
pthread_private.h libroot: add [gs]etpriority implementation 2019-01-19 18:31:58 +00:00
SHA256.h Move SHA256 class to libroot instead of linking libshared into libroot. 2017-10-03 20:18:26 -04:00
signal_private.h Merged signals-merge branch into trunk with the following changes: 2011-06-12 00:00:23 +00:00
stdlib_private.h Add private __getenv_reentrant() 2013-11-17 19:11:02 +01:00
system_revision.h
time_private.h Merged signals-merge branch into trunk with the following changes: 2011-06-12 00:00:23 +00:00
times_private.h Merged signals-merge branch into trunk with the following changes: 2011-06-12 00:00:23 +00:00
trig.h
umask.h
unistd_private.h Merged signals-merge branch into trunk with the following changes: 2011-06-12 00:00:23 +00:00
user_group.h Bump MAX_SHADOW_PWD_PASSWORD_LEN 2017-11-23 13:00:48 +01:00
user_thread.h user_thread.h: use struct keyword to be usable in C. 2016-12-17 20:17:38 +01:00
wchar_private.h Cleanup: correct variable name in mbrtowc() signature. 2012-02-07 21:43:00 +01:00