/trunk/kernel/generic/include/time/timeout.h |
---|
36,8 → 36,24 |
#define KERN_TIMEOUT_H_ |
#include <arch/types.h> |
#include <proc/task.h> |
#include <adt/list.h> |
#include <cpu.h> |
typedef void (* timeout_handler_t)(void *arg); |
typedef struct { |
SPINLOCK_DECLARE(lock); |
link_t link; /**< Link to the list of active timeouts on THE->cpu */ |
uint64_t ticks; /**< Timeout will be activated in this amount of clock() ticks. */ |
timeout_handler_t handler; /**< Function that will be called on timeout activation. */ |
void *arg; /**< Argument to be passed to handler() function. */ |
cpu_t *cpu; /**< On which processor is this timeout registered. */ |
} timeout_t; |
#define us2ticks(us) ((uint64_t) (((uint32_t) (us) / (1000000 / HZ)))) |
extern void timeout_init(void); |
/trunk/kernel/generic/include/proc/task.h |
---|
133,39 → 133,6 |
uint64_t cycles; /**< Accumulated accounting. */ |
} task_t; |
typedef void (* timeout_handler_t)(void *arg); |
typedef struct { |
SPINLOCK_DECLARE(lock); |
link_t link; /**< Link to the list of active timeouts on THE->cpu */ |
uint64_t ticks; /**< Timeout will be activated in this amount of clock() ticks. */ |
timeout_handler_t handler; /**< Function that will be called on timeout activation. */ |
void *arg; /**< Argument to be passed to handler() function. */ |
cpu_t *cpu; /**< On which processor is this timeout registered. */ |
} timeout_t; |
/** Thread states. */ |
typedef enum { |
Invalid, /**< It is an error, if thread is found in this state. */ |
Running, /**< State of a thread that is currently executing on some CPU. */ |
Sleeping, /**< Thread in this state is waiting for an event. */ |
Ready, /**< State of threads in a run queue. */ |
Entering, /**< Threads are in this state before they are first readied. */ |
Exiting, /**< After a thread calls thread_exit(), it is put into Exiting state. */ |
Undead /**< Threads that were not detached but exited are in the Undead state. */ |
} state_t; |
/** Join types. */ |
typedef enum { |
None, |
TaskClnp, /**< The thread will be joined by ktaskclnp thread. */ |
TaskGC /**< The thread will be joined by ktaskgc thread. */ |
} thread_join_type_t; |
SPINLOCK_EXTERN(tasks_lock); |
extern btree_t tasks_btree; |
/trunk/kernel/generic/include/proc/thread.h |
---|
37,6 → 37,7 |
#include <synch/waitq.h> |
#include <proc/task.h> |
#include <time/timeout.h> |
#include <cpu.h> |
#include <synch/rwlock.h> |
#include <adt/btree.h> |
55,6 → 56,24 |
#define THREAD_FLAG_STOLEN (1 << 1) /**< Thread was migrated to another CPU and has not run yet. */ |
#define THREAD_FLAG_USPACE (1 << 2) /**< Thread executes in userspace. */ |
/** Thread states. */ |
typedef enum { |
Invalid, /**< It is an error, if thread is found in this state. */ |
Running, /**< State of a thread that is currently executing on some CPU. */ |
Sleeping, /**< Thread in this state is waiting for an event. */ |
Ready, /**< State of threads in a run queue. */ |
Entering, /**< Threads are in this state before they are first readied. */ |
Exiting, /**< After a thread calls thread_exit(), it is put into Exiting state. */ |
Undead /**< Threads that were not detached but exited are in the Undead state. */ |
} state_t; |
/** Join types. */ |
typedef enum { |
None, |
TaskClnp, /**< The thread will be joined by ktaskclnp thread. */ |
TaskGC /**< The thread will be joined by ktaskgc thread. */ |
} thread_join_type_t; |
/** Thread structure. There is one per thread. */ |
typedef struct thread { |
link_t rq_link; /**< Run queue link. */ |