* For each userland team the kernel creates an area in the userland
address space that is fully locked and marked B_KERNEL_AREA. It can thus be accessed by the kernel without additional checks. * For each userland thread we do create a user_thread structure in that area. The structure is accessible from userland via TLS, using the private get_user_thread() function. * Introduced private userland functions [un]defer_signals(). They can be used to cheaply disable/re-enable signal delivery. They use the user_thread::defer_signals/pending_signals fields which are checked/updated by the kernel. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25451 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2008, Ingo Weinhold, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _LIBROOT_USER_THREAD_H
|
||||
#define _LIBROOT_USER_THREAD_H
|
||||
|
||||
#include <OS.h>
|
||||
#include <TLS.h>
|
||||
|
||||
#include <tls.h> /* kernel header */
|
||||
|
||||
|
||||
struct user_thread {
|
||||
int32 defer_signals; // counter; 0 == signals allowed
|
||||
uint32 pending_signals; // signals that are pending, when
|
||||
// signals are deferred
|
||||
status_t wait_status;
|
||||
};
|
||||
|
||||
|
||||
static inline user_thread*
|
||||
get_user_thread()
|
||||
{
|
||||
return (user_thread*)tls_get(TLS_USER_THREAD_SLOT);
|
||||
}
|
||||
|
||||
|
||||
static void inline
|
||||
defer_signals()
|
||||
{
|
||||
get_user_thread()->defer_signals++;
|
||||
}
|
||||
|
||||
|
||||
static void inline
|
||||
undefer_signals()
|
||||
{
|
||||
user_thread* thread = get_user_thread();
|
||||
if (--thread->defer_signals == 0 && thread->pending_signals != 0) {
|
||||
// signals shall no longer be deferred -- call a dummy syscall to handle
|
||||
// the pending ones
|
||||
is_computer_on();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /* _LIBROOT_USER_THREAD_H */
|
||||
Reference in New Issue
Block a user