6 Commits
Author SHA1 Message Date
Timothy GuandLeorize 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 <[email protected]>
Co-authored-by: Leorize <[email protected]>
Change-Id: Ie14f105b00fe8563d16b3562748e1c2e56c873a6
Reviewed-on: https://review.haiku-os.org/c/78
Reviewed-by: Jérôme Duval <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
2019-01-19 18:31:58 +00:00
Timothy Gu d91933c26f HIDWriter: 0-initialize struct
Fixes CID 610984.

Signed-off-by: Augustin Cavalier <[email protected]>
2015-06-23 11:59:36 -04:00
Timothy Gu 2201ddd6d0 NetFSServer: Forward errors and fix use-after-free.
At least right now, the constructor of ServerInfoSender can only fail
because of OOM.

Signed-off-by: Augustin Cavalier <[email protected]>
Fixes #11716. One minor tweak by me from the original patch
(change "!sender" to "sender == NULL").
2015-06-23 11:58:23 -04:00
Timothy Gu beb9b3453b CID991576: ICNSLoader: fix stray semicolon
Fixes #11715.

Signed-off-by: Adrien Destugues <[email protected]>
2015-01-07 08:36:30 +01:00
Timothy Gu d1dc9cf655 stdint.h: use correct type for INT64_MAX (#11647)
int64_t is signed. Although it does not make a difference by itself, because
INT64_MAX is still a valid number for uint64_t (UL), the later INT64_MIN
declaration depends on INT64_MAX, and therefore got implicitly casted to
unsigned type.

This fixes the following program on a x86_64 system:

	#include <stdint.h>

	int main() {
		int64_t test = 5;
		if (test < INT64_MIN)
			return 1;
		return 0;
	}

This is a regression since commit 1d13a609 ("stdint.h: define [U]INT64[MAX|MIN]
with [U]L on x86_64").

Signed-off-by: Jerome Duval <[email protected]>
2014-12-20 10:06:21 +01:00
Timothy Gu e7dceac3fa Outsource DejaVu fonts
Signed-off-by: Timothy Gu <[email protected]>
2014-12-16 09:39:02 +01:00