haiku/headers/private
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
..
app Revert "Fix for bug 6991, replace registrars timer tick" 2019-01-16 21:17:48 +01:00
audio audio: Move hmulti_audio driver API to private audio headers 2018-10-23 16:33:19 +02:00
binary_compatibility BControl: Add icon support 2013-12-22 02:48:25 +01:00
bluetooth bluetooth: remove DEBUG definition. 2016-06-05 18:55:44 +02:00
codec Move FormatManager back to the media_kit 2018-12-28 22:55:25 +01:00
debug Move comment to correct function. 2013-05-01 19:52:00 -04:00
debugger Debugger: Fix #14375, #12343. 2018-08-20 16:44:20 -04:00
device drivers: Deduplify joystick_driver.h. 2018-06-21 18:46:30 -04:00
drivers scsi: Use _res and not res in MK_ERROR. 2018-06-18 22:05:45 -04:00
file_systems packagefs: Move DebugSupport up into the file_systems shared folder. 2018-08-22 19:19:56 -04:00
firewire include strings.h where appriopriate... 2014-08-08 22:40:37 +02:00
fs_shell fs_shell: Added socket filetype. 2017-12-10 11:02:59 -05:00
graphics Remove private vmware driver headers. 2018-06-26 17:23:23 -04:00
index_server Add a CLucene full-text add-on. 2010-10-28 15:22:52 +00:00
input Implemented the patch on #7963 in a different way. 2011-10-31 18:09:24 +00:00
interface utf8_functions.h: Fix PVS 359 2019-01-09 17:44:19 +00:00
kernel kernel/x86: Use volatile in restore_interrupts. 2019-01-07 22:12:36 -05:00
libroot libroot: add [gs]etpriority implementation 2019-01-19 18:31:58 +00:00
locale Fix instanciate_catalog prototype 2015-01-17 17:02:40 +01:00
mail build: Cleanup of libgnuregex usage. 2018-03-07 18:04:31 -05:00
media Move FormatManager back to the media_kit 2018-12-28 22:55:25 +01:00
midi Midi: Remove some duplicated code 2015-08-27 11:51:57 +02:00
mount * Removed now obsolete notification (this was not even used in Tracker 2009-10-07 19:31:57 +00:00
net freebsd11_wlan: Remove the BOSII_* ioctls. 2018-10-04 20:07:11 -04:00
notification Notification_Server: Added ability to choose position of notifications 2017-12-24 12:02:38 +01:00
package Remove Curl, Switch to NetApi in Package Kit 2018-09-29 17:23:52 +00:00
preferences Fix glitch in Screen prefs when changing background color. 2017-04-30 10:29:39 +02:00
print PictureIterator.h: fix header guard spelling 2016-07-10 17:11:20 +02:00
runtime_loader runtime_loader: increase max length for image names. 2017-04-20 18:23:36 +02:00
screen_saver ScreenSaver: Rename BuildScreenSaverDefaultSettingsView 2016-04-13 15:50:30 -07:00
shared shared/locks: Add RecursiveLocker. 2018-12-17 19:51:45 -05:00
storage s/OpenBeOS License/MIT License/ universally, as they're the same thing. 2017-02-09 22:09:56 -05:00
support Add ZstdCompressionAlgorithm. 2017-11-24 21:35:49 +01:00
syslog_daemon syslog_daemon: Converted to BServer. 2015-07-22 20:40:47 +02:00
system kernel: Remove the B_KERNEL_AREA protection flag. 2018-11-17 16:46:49 -05:00
textencoding
tracker Tracker FindPanel: Make a copy of fDeviceIcon 2016-07-31 19:42:39 -07:00
usb_vision some copyright headers clean up 2010-04-12 21:02:09 +00:00
userlandfs userlandfs: Fix -Werror=parentheses 2018-12-04 20:46:43 +00:00
virtio virtio: Replace size return with usedLength in queue_dequeue. 2018-11-17 00:34:49 +01:00
vmdk Moved vmdkimage.h to a shareable place, cleaned it up a bit, and renamed it to 2009-10-01 03:08:46 +00:00