mirror of
https://github.com/drasko/codezero.git
synced 2026-02-06 15:03:15 +01:00
Towards finishing exchange_registers()
- Added mutex_trylock() - Implemented most of exchange_registers() - thread_control() now needs a lock for operations that can modify thread context. - thread_start() does not initialise scheduler flags, now done in thread_create. TODO: - Fork/clone'ed threads should retain their context in tcb, not syscall stack. - exchange_registers() calls in userspace need cleaning up.
This commit is contained in:
@@ -34,10 +34,6 @@ static inline struct ktcb *current_task(void)
|
||||
#define SCHED_FL_MASK (SCHED_FL_SLEEP | SCHED_FL_RESUME \
|
||||
| SCHED_FL_SUSPEND)
|
||||
|
||||
#define __IPC_FL_WAIT 4
|
||||
#define IPC_FL_WAIT (1 << __IPC_FL_WAIT)
|
||||
#define IPC_FL_MASK IPC_FL_WAIT
|
||||
|
||||
void sched_runqueue_init(void);
|
||||
void sched_start_task(struct ktcb *task);
|
||||
void sched_resume_task(struct ktcb *task);
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include INC_GLUE(memory.h)
|
||||
#include INC_GLUE(syscall.h)
|
||||
#include INC_GLUE(message.h)
|
||||
#include INC_GLUE(context.h)
|
||||
#include INC_SUBARCH(mm.h)
|
||||
|
||||
enum task_state {
|
||||
@@ -21,32 +22,6 @@ enum task_state {
|
||||
TASK_RUNNABLE = 2,
|
||||
};
|
||||
|
||||
/*
|
||||
* This describes the user space register context of each task. Simply set them
|
||||
* as regular structure fields, and they'll be copied onto real registers upon
|
||||
* a context switch. In the ARM case, they're copied from memory to userspace
|
||||
* registers using the LDM instruction with ^, no-pc flavor. See ARMARM.
|
||||
*/
|
||||
typedef struct arm_context {
|
||||
u32 spsr; /* 0x0 */
|
||||
u32 r0; /* 0x4 */
|
||||
u32 r1; /* 0x8 */
|
||||
u32 r2; /* 0xC */
|
||||
u32 r3; /* 0x10 */
|
||||
u32 r4; /* 0x14 */
|
||||
u32 r5; /* 0x18 */
|
||||
u32 r6; /* 0x1C */
|
||||
u32 r7; /* 0x20 */
|
||||
u32 r8; /* 0x24 */
|
||||
u32 r9; /* 0x28 */
|
||||
u32 r10; /* 0x2C */
|
||||
u32 r11; /* 0x30 */
|
||||
u32 r12; /* 0x34 */
|
||||
u32 sp; /* 0x38 */
|
||||
u32 lr; /* 0x3C */
|
||||
u32 pc; /* 0x40 */
|
||||
} __attribute__((__packed__)) task_context_t;
|
||||
|
||||
#define TASK_ID_INVALID -1
|
||||
struct task_ids {
|
||||
l4id_t tid;
|
||||
@@ -75,7 +50,9 @@ struct ktcb {
|
||||
|
||||
/* Flags to hint scheduler on future task state */
|
||||
unsigned int schedfl;
|
||||
unsigned int flags;
|
||||
|
||||
/* Lock for blocking thread state modifications via a syscall */
|
||||
struct mutex thread_control_lock;
|
||||
|
||||
/* Other related threads */
|
||||
l4id_t pagerid;
|
||||
|
||||
Reference in New Issue
Block a user