Merged the signals branch into trunk, with these changes:

* The team and thread kernel structures have been renamed to Team and Thread
  respectively and moved into the new BKernel namespace.
* Several (kernel add-on) sources have been converted from C to C++ since
  private kernel headers are included that are no longer C compatible.

Changes after merging:
* Fixed gcc 2 build (warnings mainly in the scary firewire bus manager).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40196 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2011-01-10 21:54:38 +00:00
parent ebf7db3afd
commit 4535495d80
139 changed files with 1303 additions and 1231 deletions
+15 -6
View File
@@ -30,11 +30,15 @@
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*
* $FreeBSD: src/sys/dev/firewire/iec13213.h,v 1.14 2005/01/06 01:42:41 imp Exp $
*
*/
#include <sys/cdefs.h>
#define STATE_CLEAR 0x0000
#define STATE_SET 0x0004
#define NODE_IDS 0x0008
@@ -161,7 +165,7 @@ struct csrtext {
struct bus_info {
#define CSR_BUS_NAME_IEEE1394 0x31333934
uint32_t bus_name;
uint32_t bus_name;
#if BYTE_ORDER == BIG_ENDIAN
uint32_t irmc:1, /* iso. resource manager capable */
cmc:1, /* cycle master capable */
@@ -209,6 +213,8 @@ struct crom_context {
struct crom_ptr stack[CROM_MAX_DEPTH];
};
__BEGIN_DECLS
void crom_init_context(struct crom_context *, uint32_t *);
struct csrreg *crom_get(struct crom_context *);
void crom_next(struct crom_context *);
@@ -232,12 +238,12 @@ struct crom_src {
struct crom_chunk {
STAILQ_ENTRY(crom_chunk) link;
struct crom_chunk *ref_chunk;
int ref_index;
struct crom_chunk *ref_chunk;
int ref_index;
int offset;
struct {
BIT16x2(crc_len, crc);
uint32_t buf[CROM_MAX_CHUNK_LEN];
uint32_t buf[CROM_MAX_CHUNK_LEN];
} data;
};
@@ -246,6 +252,9 @@ extern int crom_add_entry(struct crom_chunk *, int, int);
extern int crom_add_chunk(struct crom_src *src, struct crom_chunk *,
struct crom_chunk *, int);
extern int crom_add_simple_text(struct crom_src *src, struct crom_chunk *,
struct crom_chunk *, char *);
struct crom_chunk *, const char *);
extern int crom_load(struct crom_src *, uint32_t *, int);
#endif
__END_DECLS
@@ -22,9 +22,9 @@ struct iframe *arm_get_user_iframe(void);
/* as we won't support SMP on arm (yet?) we can use a global here */
/*TODO SMP-ARMS are comming..*/
extern struct thread *gCurrentThread;
extern Thread *gCurrentThread;
extern inline struct thread *
extern inline Thread *
arch_thread_get_current_thread(void)
{
return gCurrentThread;
@@ -32,7 +32,7 @@ arch_thread_get_current_thread(void)
extern inline void
arch_thread_set_current_thread(struct thread *t)
arch_thread_set_current_thread(Thread *t)
{
gCurrentThread = t;
}
+7 -2
View File
@@ -16,7 +16,12 @@
struct kernel_args;
struct thread;
namespace BKernel {
struct Thread;
}
using BKernel::Thread;
// arch_debug_get_stack_trace() flags
@@ -34,7 +39,7 @@ void *arch_debug_get_caller(void);
int32 arch_debug_get_stack_trace(addr_t* returnAddresses, int32 maxCount,
int32 skipIframes, int32 skipFrames, uint32 flags);
void* arch_debug_get_interrupt_pc(bool* _isSyscall);
bool arch_debug_contains_call(struct thread *thread, const char *symbol,
bool arch_debug_contains_call(Thread *thread, const char *symbol,
addr_t start, addr_t end);
void arch_debug_save_registers(struct arch_debug_registers* registers);
void arch_debug_unset_current_thread(void);
+4 -4
View File
@@ -22,7 +22,7 @@
#ifndef _ASSEMBLER
/* 68k has many different possible stack frames, differentiated by a 4 bit number,
/* 68k has many different possible stack frames, differentiated by a 4 bit number,
* but they also depend on the cpu type.
* cf. mint/sys/arch/check_exc.h
*/
@@ -283,7 +283,7 @@ struct iframe {
struct mc680x0_fp_control_regs fpc;
/* fpu state */
struct mc680x0_fpu_state fpu;
/* data and address registers */
uint32 d[8];
uint32 a[7];
@@ -517,7 +517,7 @@ extern int arch_machine;
Use of (some) special purpose registers.
XXX: those regs aren't implemented/accessed the same way on different cpus...
SRP[63-32]: current struct thread*
SRP[63-32]: current Thread*
SRP[31-0] :
CAAR : can we use it ??
MSP :
@@ -526,7 +526,7 @@ extern int arch_machine;
SPRG0: per CPU physical address pointer to an ppc_cpu_exception_context
structure
SPRG1: scratch
SPRG2: current struct thread*
SPRG2: current Thread*
SPRG3: TLS base pointer (only for userland threads)
*/
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2006, Haiku Inc. All rights reserved.
* Copyright 2003-2011, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -20,9 +20,9 @@ void m68k_pop_iframe(struct iframe_stack *stack);
struct iframe *m68k_get_user_iframe(void);
/* as we won't support SMP on m68k (yet?) we can use a global here */
extern struct thread *gCurrentThread;
extern Thread *gCurrentThread;
extern inline struct thread *
extern inline Thread *
arch_thread_get_current_thread(void)
{
return gCurrentThread;
@@ -30,7 +30,7 @@ arch_thread_get_current_thread(void)
extern inline void
arch_thread_set_current_thread(struct thread *t)
arch_thread_set_current_thread(Thread *t)
{
gCurrentThread = t;
}
@@ -38,17 +38,17 @@ arch_thread_set_current_thread(struct thread *t)
#if 0
/* this would only work on 030... */
extern inline struct thread *
extern inline Thread *
arch_thread_get_current_thread(void)
{
uint64 v = 0;
asm volatile("pmove %%srp,(%0)" : : "a"(&v));
return (struct thread *)(uint32)(v & 0xffffffff);
return (Thread *)(uint32)(v & 0xffffffff);
}
extern inline void
arch_thread_set_current_thread(struct thread *t)
arch_thread_set_current_thread(Thread *t)
{
uint64 v;
asm volatile("pmove %%srp,(%0)\n" \
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2009, Haiku Inc. All rights reserved.
* Copyright 2003-2011, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -22,17 +22,17 @@ void mipsel_pop_iframe(struct iframe_stack* stack);
struct iframe* mipsel_get_user_iframe(void);
static inline struct thread*
static inline Thread*
arch_thread_get_current_thread(void)
{
#warning IMPLEMENT arch_thread_get_current_thread
struct thread* t;
Thread* t;
return t;
}
static inline void
arch_thread_set_current_thread(struct thread* t)
arch_thread_set_current_thread(Thread* t)
{
#warning IMPLEMENT arch_thread_set_current_thread
}
+1 -1
View File
@@ -206,7 +206,7 @@ enum ppc_processor_version {
SPRG0: per CPU physical address pointer to an ppc_cpu_exception_context
structure
SPRG1: scratch
SPRG2: current struct thread*
SPRG2: current Thread*
SPRG3: TLS base pointer (only for userland threads)
*/
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2006, Haiku Inc. All rights reserved.
* Copyright 2003-2011, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -20,17 +20,17 @@ void ppc_pop_iframe(struct iframe_stack *stack);
struct iframe *ppc_get_user_iframe(void);
static inline struct thread *
static inline Thread *
arch_thread_get_current_thread(void)
{
struct thread *t;
Thread *t;
asm volatile("mfsprg2 %0" : "=r"(t));
return t;
}
static inline void
arch_thread_set_current_thread(struct thread *t)
arch_thread_set_current_thread(Thread *t)
{
asm volatile("mtsprg2 %0" : : "r"(t));
}
+8 -8
View File
@@ -17,18 +17,18 @@ extern "C" {
#endif
status_t arch_thread_init(struct kernel_args *args);
status_t arch_team_init_team_struct(struct team *t, bool kernel);
status_t arch_thread_init_thread_struct(struct thread *t);
status_t arch_thread_init_tls(struct thread *thread);
void arch_thread_context_switch(struct thread *t_from, struct thread *t_to);
status_t arch_thread_init_kthread_stack(struct thread *t,
status_t arch_team_init_team_struct(Team *t, bool kernel);
status_t arch_thread_init_thread_struct(Thread *t);
status_t arch_thread_init_tls(Thread *thread);
void arch_thread_context_switch(Thread *t_from, Thread *t_to);
status_t arch_thread_init_kthread_stack(Thread *t,
int (*start_func)(void), void (*entry_func)(void), void (*exit_func)(void));
void arch_thread_dump_info(void *info);
status_t arch_thread_enter_userspace(struct thread *t, addr_t entry,
status_t arch_thread_enter_userspace(Thread *t, addr_t entry,
void *args1, void *args2);
bool arch_on_signal_stack(struct thread *thread);
status_t arch_setup_signal_frame(struct thread *t, struct sigaction *sa,
bool arch_on_signal_stack(Thread *thread);
status_t arch_setup_signal_frame(Thread *t, struct sigaction *sa,
int signal, int signalMask);
int64 arch_restore_signal_frame(void);
+3 -2
View File
@@ -1,10 +1,11 @@
/*
* Copyright 2005, Ingo Weinhold, [email protected].
* Copyright 2005-2011, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef KERNEL_ARCH_USER_DEBUGGER_H
#define KERNEL_ARCH_USER_DEBUGGER_H
#include "kernel_debug_config.h"
#ifndef _ASSEMBLER
@@ -17,7 +18,7 @@ extern "C" {
struct arch_team_debug_info;
struct arch_thread_debug_info;
struct thread;
void arch_clear_team_debug_info(struct arch_team_debug_info *info);
void arch_destroy_team_debug_info(struct arch_team_debug_info *info);
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009, The Haiku Team. All rights reserved.
* Copyright 2002-2011, The Haiku Team. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Copyright 2002, Travis Geiselbrecht. All rights reserved.
@@ -18,9 +18,9 @@ extern "C" {
struct iframe *i386_get_user_iframe(void);
struct iframe *i386_get_current_iframe(void);
struct iframe *i386_get_thread_user_iframe(struct thread *thread);
struct iframe *i386_get_thread_user_iframe(Thread *thread);
uint32 x86_next_page_directory(struct thread *from, struct thread *to);
uint32 x86_next_page_directory(Thread *from, Thread *to);
void x86_restart_syscall(struct iframe* frame);
@@ -33,16 +33,16 @@ void arch_syscall_64_bit_return_value(void);
static
inline struct thread *
inline Thread *
arch_thread_get_current_thread(void)
{
struct thread *t;
Thread *t;
read_dr3(t);
return t;
}
static inline void
arch_thread_set_current_thread(struct thread *t)
arch_thread_set_current_thread(Thread *t)
{
write_dr3(t);
}
@@ -1,14 +1,15 @@
/*
* Copyright 2005-2009, Ingo Weinhold, [email protected].
* Copyright 2005-2011, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_ARCH_X86_USER_DEBUGGER_H
#define _KERNEL_ARCH_X86_USER_DEBUGGER_H
#define ARCH_INIT_USER_DEBUG x86_init_user_debug
// number of breakpoints the CPU supports
// Actually it supports 4, but DR3 is used to hold the struct thread*.
// Actually it supports 4, but DR3 is used to hold the Thread*.
#define X86_BREAKPOINT_COUNT 3
// debug status register DR6
@@ -116,7 +117,6 @@ extern "C" {
#endif
struct iframe;
struct thread;
extern void x86_init_user_debug_at_kernel_exit(struct iframe *frame);
extern void x86_exit_user_debug_at_kernel_entry();
@@ -137,4 +137,5 @@ extern void x86_init_user_debug();
#define DEBUG_SOFTWARE_BREAKPOINT_SIZE 1
#define DEBUG_SHARED_BREAK_AND_WATCHPOINTS 1
#endif // _KERNEL_ARCH_X86_USER_DEBUGGER_H
+2 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2007-2008, Ingo Weinhold, [email protected].de.
* Copyright 2007-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_CONDITION_VARIABLE_H
@@ -41,7 +41,7 @@ private:
private:
ConditionVariable* fVariable;
struct thread* fThread;
Thread* fThread;
status_t fWaitStatus;
friend struct ConditionVariable;
+7 -2
View File
@@ -23,7 +23,12 @@
struct kernel_args;
struct thread;
namespace BKernel {
struct Thread;
}
using BKernel::Thread;
/* CPU local data structure */
@@ -45,7 +50,7 @@ typedef struct cpu_ent {
addr_t fault_handler_stack_pointer;
jmp_buf fault_jump_buffer;
struct thread* running_thread;
Thread* running_thread;
bool invoke_scheduler;
bool invoke_scheduler_if_idle;
bool disabled;
+20 -4
View File
@@ -17,6 +17,22 @@
#include "kernel_debug_config.h"
// We need the BKernel::Thread type below (opaquely) in the exported C
// functions below. Since this header is currently still included by plain C
// code, we define a dummy type BKernel_Thread in C mode and a equally named
// macro in C++ mode.
#ifdef __cplusplus
namespace BKernel {
struct Thread;
}
using BKernel::Thread;
# define BKernel_Thread Thread
#else
typedef struct BKernel_Thread BKernel_Thread;
#endif
/* KDEBUG
The kernel debug level.
Level 1 is usual asserts, > 1 should be used for very expensive runtime
@@ -180,8 +196,8 @@ extern status_t debug_get_next_demangled_argument(uint32* _cookie,
const char* symbol, char* name, size_t nameSize,
int32* _type, size_t* _argumentLength);
extern struct thread* debug_set_debugged_thread(struct thread* thread);
extern struct thread* debug_get_debugged_thread();
extern BKernel_Thread* debug_set_debugged_thread(BKernel_Thread* thread);
extern BKernel_Thread* debug_get_debugged_thread();
extern bool debug_is_debugged_team(team_id teamID);
extern struct arch_debug_registers* debug_get_debug_registers(int32 cpu);
@@ -197,7 +213,7 @@ extern void _user_debug_output(const char *userString);
#ifdef __cplusplus
struct DebuggedThreadSetter {
DebuggedThreadSetter(struct thread* thread)
DebuggedThreadSetter(Thread* thread)
:
fPreviousThread(debug_set_debugged_thread(thread))
{
@@ -209,7 +225,7 @@ struct DebuggedThreadSetter {
}
private:
struct thread* fPreviousThread;
Thread* fPreviousThread;
};
+3 -2
View File
@@ -20,7 +20,8 @@ struct kernel_args;
extern "C" {
#endif
status_t elf_load_user_image(const char *path, struct team *team, int flags, addr_t *_entry);
status_t elf_load_user_image(const char *path, Team *team, int flags,
addr_t *_entry);
// these two might get public one day:
image_id load_kernel_add_on(const char *path);
@@ -29,7 +30,7 @@ status_t unload_kernel_add_on(image_id id);
status_t elf_debug_lookup_symbol_address(addr_t address, addr_t *_baseAddress,
const char **_symbolName, const char **_imageName,
bool *_exactMatch);
status_t elf_debug_lookup_user_symbol_address(struct team* team, addr_t address,
status_t elf_debug_lookup_user_symbol_address(Team* team, addr_t address,
addr_t *_baseAddress, const char **_symbolName,
const char **_imageName, bool *_exactMatch);
addr_t elf_debug_lookup_symbol(const char* searchName);
+12 -6
View File
@@ -9,7 +9,13 @@
struct image;
struct team;
namespace BKernel {
struct Team;
}
using BKernel::Team;
#ifdef __cplusplus
@@ -35,16 +41,16 @@ struct image {
extern "C" {
#endif
extern image_id register_image(struct team *team, image_info *info, size_t size);
extern status_t unregister_image(struct team *team, image_id id);
extern int32 count_images(struct team *team);
extern status_t remove_images(struct team *team);
extern image_id register_image(Team *team, image_info *info, size_t size);
extern status_t unregister_image(Team *team, image_id id);
extern int32 count_images(Team *team);
extern status_t remove_images(Team *team);
typedef bool (*image_iterator_callback)(struct image* image, void* cookie);
struct image* image_iterate_through_images(image_iterator_callback callback,
void* cookie);
extern status_t image_debug_lookup_user_symbol_address(struct team *team,
extern status_t image_debug_lookup_user_symbol_address(Team *team,
addr_t address, addr_t *_baseAddress, const char **_symbolName,
const char **_imageName, bool *_exactMatch);
extern status_t image_init(void);
+7 -8
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2010, Ingo Weinhold, [email protected].
* Copyright 2008-2011, Ingo Weinhold, [email protected].
* Copyright 2005-2010, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*/
@@ -14,25 +14,24 @@
struct scheduling_analysis;
struct thread;
struct SchedulerListener;
struct scheduler_ops {
void (*enqueue_in_run_queue)(struct thread* thread);
void (*enqueue_in_run_queue)(Thread* thread);
void (*reschedule)(void);
void (*set_thread_priority)(struct thread* thread, int32 priority);
bigtime_t (*estimate_max_scheduling_latency)(struct thread* thread);
void (*set_thread_priority)(Thread* thread, int32 priority);
bigtime_t (*estimate_max_scheduling_latency)(Thread* thread);
void (*on_thread_create)(struct thread* thread);
void (*on_thread_create)(Thread* thread);
// called when the thread structure is first created -
// initialization of per-thread housekeeping data structures should
// be done here
void (*on_thread_init)(struct thread* thread);
void (*on_thread_init)(Thread* thread);
// called when a thread structure is initialized and made ready for
// use - should be used to reset the housekeeping data structures
// if needed
void (*on_thread_destroy)(struct thread* thread);
void (*on_thread_destroy)(Thread* thread);
// called when a thread structure is freed - freeing up any allocated
// mem on the scheduler's part should be done here
+8 -1
View File
@@ -10,6 +10,13 @@
#include <signal.h>
namespace BKernel {
struct Thread;
}
using BKernel::Thread;
#define KILL_SIGNALS ((1L << (SIGKILL - 1)) | (1L << (SIGKILLTHR - 1)))
#define SIGNAL_TO_MASK(signal) (1LL << (signal - 1))
@@ -24,7 +31,7 @@
extern "C" {
#endif
extern bool handle_signals(struct thread *thread);
extern bool handle_signals(Thread *thread);
extern bool is_kill_signal_pending(void);
extern int has_signals_pending(void *_thread);
extern bool is_signal_blocked(int signal);
+6 -6
View File
@@ -1,10 +1,11 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Copyright 2009-2011, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef KERNEL_LISTENERS_H
#define KERNEL_LISTENERS_H
#include <KernelExport.h>
#include <util/AutoLock.h>
@@ -14,7 +15,6 @@
struct ConditionVariable;
struct mutex;
struct rw_lock;
struct thread;
// scheduler listeners
@@ -24,11 +24,11 @@ struct SchedulerListener : DoublyLinkedListLinkImpl<SchedulerListener> {
virtual ~SchedulerListener();
virtual void ThreadEnqueuedInRunQueue(
struct thread* thread) = 0;
Thread* thread) = 0;
virtual void ThreadRemovedFromRunQueue(
struct thread* thread) = 0;
virtual void ThreadScheduled(struct thread* oldThread,
struct thread* newThread) = 0;
Thread* thread) = 0;
virtual void ThreadScheduled(Thread* oldThread,
Thread* newThread) = 0;
};
+1 -1
View File
@@ -32,7 +32,7 @@ extern "C" {
#endif
status_t port_init(struct kernel_args *args);
void delete_owned_ports(struct team* team);
void delete_owned_ports(Team* team);
int32 port_max_ports(void);
int32 port_used_ports(void);
+8 -1
View File
@@ -14,10 +14,17 @@
#include <posix/xsi_semaphore_defs.h>
namespace BKernel {
struct Team;
}
using BKernel::Team;
__BEGIN_DECLS
extern void xsi_sem_init();
extern void xsi_sem_undo(struct team *team);
extern void xsi_sem_undo(Team *team);
/* user calls */
int _user_xsi_semget(key_t key, int numberOfSemaphores, int flags);
+1 -1
View File
@@ -22,7 +22,7 @@ extern "C" {
#endif
extern status_t haiku_sem_init(struct kernel_args *args);
extern void sem_delete_owned_sems(struct team* team);
extern void sem_delete_owned_sems(Team* team);
extern int32 sem_used_sems(void);
extern int32 sem_max_sems(void);
+11 -10
View File
@@ -1,10 +1,11 @@
/*
* Copyright 2008, Haiku Inc. All rights reserved.
* Copyright 2008-2011, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _KERNEL_SYSCALL_RESTART_H
#define _KERNEL_SYSCALL_RESTART_H
#include <OS.h>
#include <thread.h>
@@ -20,7 +21,7 @@ syscall_restart_handle_timeout_pre(bigtime_t& timeout)
{
// If restarted, get the timeout from the restart parameters. Otherwise
// convert relative timeout to an absolute one.
struct thread* thread = thread_get_current_thread();
Thread* thread = thread_get_current_thread();
if ((thread->flags & THREAD_FLAGS_SYSCALL_RESTARTED) != 0)
timeout = *(bigtime_t*)thread->syscall_restart.parameters;
else if (timeout >= 0) {
@@ -44,7 +45,7 @@ syscall_restart_handle_timeout_pre(uint32& flags, bigtime_t& timeout)
// convert relative timeout to an absolute one. Note that we preserve
// relative 0 us timeouts, so that the syscall can still decide whether to
// return B_WOULD_BLOCK instead of B_TIMED_OUT.
struct thread* thread = thread_get_current_thread();
Thread* thread = thread_get_current_thread();
if ((thread->flags & THREAD_FLAGS_SYSCALL_RESTARTED) != 0) {
timeout = *(bigtime_t*)thread->syscall_restart.parameters;
if (timeout > 0 && (flags & B_RELATIVE_TIMEOUT) != 0)
@@ -67,7 +68,7 @@ syscall_restart_handle_timeout_post(status_t error, bigtime_t timeout)
{
if (error == B_INTERRUPTED) {
// interrupted -- store timeout and set flag for syscall restart
struct thread* thread = thread_get_current_thread();
Thread* thread = thread_get_current_thread();
*(bigtime_t*)thread->syscall_restart.parameters = timeout;
atomic_or(&thread->flags, THREAD_FLAGS_RESTART_SYSCALL);
}
@@ -81,7 +82,7 @@ syscall_restart_handle_post(status_t error)
{
if (error == B_INTERRUPTED) {
// interrupted -- set flag for syscall restart
struct thread* thread = thread_get_current_thread();
Thread* thread = thread_get_current_thread();
atomic_or(&thread->flags, THREAD_FLAGS_RESTART_SYSCALL);
}
@@ -92,7 +93,7 @@ syscall_restart_handle_post(status_t error)
static inline bool
syscall_restart_is_restarted()
{
struct thread* thread = thread_get_current_thread();
Thread* thread = thread_get_current_thread();
return (thread->flags & THREAD_FLAGS_SYSCALL) != 0
&& (thread->flags & THREAD_FLAGS_SYSCALL_RESTARTED) != 0;
@@ -114,8 +115,8 @@ struct SyscallFlagUnsetter {
}
private:
struct thread* fThread;
bool fWasSyscall;
Thread* fThread;
bool fWasSyscall;
};
@@ -147,8 +148,8 @@ struct SyscallRestartWrapper {
operator Type() const { return fResult; }
private:
Type fResult;
struct thread* fThread;
Type fResult;
Thread* fThread;
};
+12 -12
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2009, Haiku Inc. All Rights Reserved.
* Copyright 2004-2011, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _TEAM_H
@@ -22,34 +22,34 @@ extern "C" {
status_t team_init(struct kernel_args *args);
status_t wait_for_team(team_id id, status_t *returnCode);
void team_remove_team(struct team *team);
port_id team_shutdown_team(struct team *team, cpu_status& state);
void team_delete_team(struct team *team, port_id debuggerPort);
void team_remove_team(Team *team);
port_id team_shutdown_team(Team *team, cpu_status& state);
void team_delete_team(Team *team, port_id debuggerPort);
struct process_group *team_get_process_group_locked(
struct process_session *session, pid_t id);
void team_delete_process_group(struct process_group *group);
struct team *team_get_kernel_team(void);
Team *team_get_kernel_team(void);
team_id team_get_kernel_team_id(void);
team_id team_get_current_team_id(void);
status_t team_get_address_space(team_id id,
struct VMAddressSpace **_addressSpace);
char **user_team_get_arguments(void);
int user_team_get_arg_count(void);
struct job_control_entry* team_get_death_entry(struct team *team,
struct job_control_entry* team_get_death_entry(Team *team,
thread_id child, bool* _deleteEntry);
bool team_is_valid(team_id id);
struct team *team_get_team_struct_locked(team_id id);
Team *team_get_team_struct_locked(team_id id);
int32 team_max_teams(void);
int32 team_used_teams(void);
typedef bool (*team_iterator_callback)(struct team* team, void* cookie);
struct team* team_iterate_through_teams(team_iterator_callback callback,
typedef bool (*team_iterator_callback)(Team* team, void* cookie);
Team* team_iterate_through_teams(team_iterator_callback callback,
void* cookie);
thread_id load_image_etc(int32 argCount, const char* const* args,
const char* const* env, int32 priority, team_id parentID, uint32 flags);
void team_set_job_control_state(struct team* team, job_control_state newState,
void team_set_job_control_state(Team* team, job_control_state newState,
int signal, bool threadsLocked);
void team_set_controlling_tty(int32 index);
int32 team_get_controlling_tty();
@@ -60,8 +60,8 @@ status_t start_watching_team(team_id team, void (*hook)(team_id, void *),
status_t stop_watching_team(team_id team, void (*hook)(team_id, void *),
void *data);
struct user_thread* team_allocate_user_thread(struct team* team);
void team_free_user_thread(struct thread* thread);
struct user_thread* team_allocate_user_thread(Team* team);
void team_free_user_thread(Thread* thread);
bool team_associate_data(AssociatedData* data);
bool team_dissociate_data(AssociatedData* data);
+20 -20
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2008-2009, Ingo Weinhold, [email protected].
* Copyright 2008-2011, Ingo Weinhold, [email protected].
* Copyright 2002-2007, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*
@@ -35,10 +35,10 @@ struct thread_creation_attributes;
extern "C" {
#endif
void thread_enqueue(struct thread *t, struct thread_queue *q);
struct thread *thread_lookat_queue(struct thread_queue *q);
struct thread *thread_dequeue(struct thread_queue *q);
struct thread *thread_dequeue_id(struct thread_queue *q, thread_id id);
void thread_enqueue(Thread *t, struct thread_queue *q);
Thread *thread_lookat_queue(struct thread_queue *q);
Thread *thread_dequeue(struct thread_queue *q);
Thread *thread_dequeue_id(struct thread_queue *q, thread_id id);
void thread_at_kernel_entry(bigtime_t now);
// called when the thread enters the kernel on behalf of the thread
@@ -54,32 +54,32 @@ void thread_exit(void);
int32 thread_max_threads(void);
int32 thread_used_threads(void);
const char* thread_state_to_text(struct thread* thread, int32 state);
const char* thread_state_to_text(Thread* thread, int32 state);
int32 thread_get_io_priority(thread_id id);
void thread_set_io_priority(int32 priority);
#define thread_get_current_thread arch_thread_get_current_thread
struct thread *thread_get_thread_struct(thread_id id);
struct thread *thread_get_thread_struct_locked(thread_id id);
Thread *thread_get_thread_struct(thread_id id);
Thread *thread_get_thread_struct_locked(thread_id id);
static thread_id thread_get_current_thread_id(void);
static inline thread_id
thread_get_current_thread_id(void)
{
struct thread *thread = thread_get_current_thread();
Thread *thread = thread_get_current_thread();
return thread ? thread->id : 0;
}
static inline bool
thread_is_idle_thread(struct thread *thread)
thread_is_idle_thread(Thread *thread)
{
return thread->entry == NULL;
}
typedef bool (*thread_iterator_callback)(struct thread* thread, void* cookie);
struct thread* thread_iterate_through_threads(thread_iterator_callback callback,
typedef bool (*thread_iterator_callback)(Thread* thread, void* cookie);
Thread* thread_iterate_through_threads(thread_iterator_callback callback,
void* cookie);
thread_id allocate_thread_id(void);
@@ -140,7 +140,7 @@ int _user_setrlimit(int resource, const struct rlimit * rlp);
Thread lock can be, but doesn't need to be held.
*/
static inline bool
thread_is_interrupted(struct thread* thread, uint32 flags)
thread_is_interrupted(Thread* thread, uint32 flags)
{
return ((flags & B_CAN_INTERRUPT)
&& (thread->sig_pending & ~thread->sig_block_mask) != 0)
@@ -150,7 +150,7 @@ thread_is_interrupted(struct thread* thread, uint32 flags)
static inline bool
thread_is_blocked(struct thread* thread)
thread_is_blocked(Thread* thread)
{
return thread->wait.status == 1;
}
@@ -161,7 +161,7 @@ thread_is_blocked(struct thread* thread)
Thread lock can be, but doesn't need to be locked.
*/
static inline void
thread_prepare_to_block(struct thread* thread, uint32 flags, uint32 type,
thread_prepare_to_block(Thread* thread, uint32 flags, uint32 type,
const void* object)
{
thread->wait.flags = flags;
@@ -174,7 +174,7 @@ thread_prepare_to_block(struct thread* thread, uint32 flags, uint32 type,
static inline status_t
thread_block_locked(struct thread* thread)
thread_block_locked(Thread* thread)
{
if (thread->wait.status == 1) {
// check for signals, if interruptable
@@ -191,7 +191,7 @@ thread_block_locked(struct thread* thread)
static inline void
thread_unblock_locked(struct thread* thread, status_t status)
thread_unblock_locked(Thread* thread, status_t status)
{
if (atomic_test_and_set(&thread->wait.status, status, 1) != 1)
return;
@@ -203,7 +203,7 @@ thread_unblock_locked(struct thread* thread, status_t status)
static inline status_t
thread_interrupt(struct thread* thread, bool kill)
thread_interrupt(Thread* thread, bool kill)
{
if ((thread->wait.flags & B_CAN_INTERRUPT) != 0
|| (kill && (thread->wait.flags & B_KILL_CAN_INTERRUPT) != 0)) {
@@ -216,14 +216,14 @@ thread_interrupt(struct thread* thread, bool kill)
static inline void
thread_pin_to_current_cpu(struct thread* thread)
thread_pin_to_current_cpu(Thread* thread)
{
thread->pinned_to_cpu++;
}
static inline void
thread_unpin_from_current_cpu(struct thread* thread)
thread_unpin_from_current_cpu(Thread* thread)
{
thread->pinned_to_cpu--;
}
+45 -29
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2010, Haiku Inc.
* Copyright 2004-2011, Haiku, Inc.
* Distributed under the terms of the MIT License.
*
* Thread definition and structures
@@ -58,14 +58,22 @@ typedef enum job_control_state {
} job_control_state;
struct cpu_ent;
struct image; // defined in image.c
struct io_context;
struct realtime_sem_context; // defined in realtime_sem.cpp
struct scheduler_thread_data;
struct select_info;
struct user_thread; // defined in libroot/user_thread.h
struct VMAddressSpace;
struct xsi_sem_context; // defined in xsi_semaphore.cpp
namespace BKernel {
struct Team;
struct Thread;
}
struct death_entry {
struct list_link link;
pid_t group_id;
@@ -88,12 +96,12 @@ struct process_group {
struct process_session *session;
pid_t id;
int32 refs;
struct team *teams;
BKernel::Team *teams;
bool orphaned;
};
struct team_loading_info {
struct thread *thread; // the waiting thread
Thread* thread; // the waiting thread
status_t result; // the result of the loading
bool done; // set when loading is done/aborted
};
@@ -117,7 +125,7 @@ struct job_control_entry : DoublyLinkedListLinkImpl<job_control_entry> {
bool has_group_ref;
// valid while state != JOB_CONTROL_STATE_DEAD
struct team* team;
BKernel::Team* team;
// valid when state == JOB_CONTROL_STATE_DEAD
pid_t group_id;
@@ -199,12 +207,20 @@ private:
};
struct team : AssociatedDataOwner {
struct team *next; // next in hash
struct team *siblings_next;
struct team *parent;
struct team *children;
struct team *group_next;
typedef int32 (*thread_entry_func)(thread_func, void *);
typedef bool (*page_fault_callback)(addr_t address, addr_t faultAddress,
bool isWrite);
namespace BKernel {
struct Team : AssociatedDataOwner {
Team *next; // next in hash
Team *siblings_next;
Team *parent;
Team *children;
Team *group_next;
team_id id;
pid_t group_id;
pid_t session_id;
@@ -221,16 +237,14 @@ struct team : AssociatedDataOwner {
struct list dead_threads;
int dead_threads_count;
// TODO: Remove the no longer necessary level of indirection for the
// following members.
team_dead_children *dead_children;
team_job_control_children *stopped_children;
team_job_control_children *continued_children;
team_dead_children dead_children;
team_job_control_children stopped_children;
team_job_control_children continued_children;
struct job_control_entry* job_control_entry;
struct VMAddressSpace *address_space;
struct thread *main_thread;
struct thread *thread_list;
VMAddressSpace *address_space;
Thread *main_thread;
Thread *thread_list;
struct team_loading_info *loading_info;
struct list image_list;
struct list watcher_list;
@@ -259,18 +273,14 @@ struct team : AssociatedDataOwner {
int supplementary_group_count;
};
typedef int32 (*thread_entry_func)(thread_func, void *);
typedef bool (*page_fault_callback)(addr_t address, addr_t faultAddress,
bool isWrite);
struct thread {
struct Thread {
int32 flags; // summary of events relevant in interrupt
// handlers (signals pending, user debugging
// enabled, etc.)
struct thread *all_next;
struct thread *team_next;
struct thread *queue_next; /* i.e. run queue, release queue, etc. */
Thread *all_next;
Thread *team_next;
Thread *queue_next; /* i.e. run queue, release queue, etc. */
timer alarm;
thread_id id;
char name[B_OS_NAME_LENGTH];
@@ -332,7 +342,7 @@ struct thread {
thread_entry_func entry;
void *args1, *args2;
struct team *team;
BKernel::Team *team;
struct {
sem_id sem;
@@ -370,9 +380,15 @@ struct thread {
struct arch_thread arch_info;
};
} // namespace BKernel
using BKernel::Team;
using BKernel::Thread;
struct thread_queue {
struct thread *head;
struct thread *tail;
Thread* head;
Thread* tail;
};
+3 -3
View File
@@ -100,9 +100,9 @@ class AbstractTraceEntry : public TraceEntry {
virtual void AddDump(TraceOutput& out);
thread_id Thread() const { return fThread; }
thread_id Team() const { return fTeam; }
bigtime_t Time() const { return fTime; }
thread_id ThreadID() const { return fThread; }
thread_id TeamID() const { return fTeam; }
bigtime_t Time() const { return fTime; }
protected:
thread_id fThread;
+11 -5
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2005-2009, Ingo Weinhold, [email protected].
* Copyright 2005-2011, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*
* Userland debugger support.
@@ -24,7 +24,13 @@
struct BreakpointManager;
struct ConditionVariable;
struct function_profile_info;
struct thread;
namespace BKernel {
struct Thread;
}
using BKernel::Thread;
// Team related debugging data.
//
@@ -235,15 +241,15 @@ void user_debug_team_exec();
void user_debug_update_new_thread_flags(thread_id threadID);
void user_debug_thread_created(thread_id threadID);
void user_debug_thread_deleted(team_id teamID, thread_id threadID);
void user_debug_thread_exiting(struct thread* thread);
void user_debug_thread_exiting(Thread* thread);
void user_debug_image_created(const image_info *imageInfo);
void user_debug_image_deleted(const image_info *imageInfo);
void user_debug_breakpoint_hit(bool software);
void user_debug_watchpoint_hit();
void user_debug_single_stepped();
void user_debug_thread_unscheduled(struct thread* thread);
void user_debug_thread_scheduled(struct thread* thread);
void user_debug_thread_unscheduled(Thread* thread);
void user_debug_thread_scheduled(Thread* thread);
// syscalls
+9 -6
View File
@@ -5,12 +5,17 @@
#ifndef _KERNEL_USERGROUP_H
#define _KERNEL_USERGROUP_H
#include <unistd.h>
#include <SupportDefs.h>
struct team;
namespace BKernel {
struct Team;
}
using BKernel::Team;
#ifdef __cplusplus
@@ -19,11 +24,9 @@ extern "C" {
// kernel private functions
void inherit_parent_user_and_group(struct team* team,
struct team* parent);
void inherit_parent_user_and_group_locked(struct team* team,
struct team* parent);
status_t update_set_id_user_and_group(struct team* team, const char* file);
void inherit_parent_user_and_group(Team* team, Team* parent);
void inherit_parent_user_and_group_locked(Team* team, Team* parent);
status_t update_set_id_user_and_group(Team* team, const char* file);
// syscalls
+4 -4
View File
@@ -1,6 +1,6 @@
/*
* Copyright 2008-2009, Axel Dörfler, [email protected].
* Copyright 2005-2007, Ingo Weinhold, [email protected]. All rights reserved.
* Copyright 2005-2011, Ingo Weinhold, [email protected].
*
* Distributed under the terms of the MIT License.
*/
@@ -162,19 +162,19 @@ typedef AutoLocker<spinlock, InterruptsSpinLocking> InterruptsSpinLocker;
class ThreadCPUPinLocking {
public:
inline bool Lock(struct thread* thread)
inline bool Lock(Thread* thread)
{
thread_pin_to_current_cpu(thread);
return true;
}
inline void Unlock(struct thread* thread)
inline void Unlock(Thread* thread)
{
thread_unpin_from_current_cpu(thread);
}
};
typedef AutoLocker<struct thread, ThreadCPUPinLocking> ThreadCPUPinner;
typedef AutoLocker<Thread, ThreadCPUPinLocking> ThreadCPUPinner;
} // namespace BPrivate
+5 -4
View File
@@ -401,7 +401,7 @@ protected:
return true;
}
void _Resize(ValueType** newTable, size_t newSize, void** oldTable = NULL)
void _Resize(ValueType** newTable, size_t newSize, void** _oldTable = NULL)
{
for (size_t i = 0; i < newSize; i++)
newTable[i] = NULL;
@@ -416,11 +416,12 @@ protected:
}
}
if (oldTable != NULL)
*oldTable = fTable;
if (_oldTable != NULL)
*_oldTable = fTable;
else
fAllocator.Free(fTable);
}
} else if (_oldTable != NULL)
*_oldTable = NULL;
fTableSize = newSize;
fTable = newTable;
-1
View File
@@ -19,7 +19,6 @@ struct generic_io_vec;
struct kernel_args;
struct ObjectCache;
struct system_memory_info;
struct team;
struct VMAddressSpace;
struct VMArea;
struct VMCache;