ia64/xen-unstable

annotate extras/mini-os/include/sched.h @ 12473:0839db0aa611

[MINIOS] Add timer support.

Based on an original patch by Robert Kaiser.

Signed-off-by: Grzegorz Milos <gm281@cam.ac.uk>
author kfraser@localhost.localdomain
date Wed Nov 15 09:33:01 2006 +0000 (2006-11-15)
parents f6507937cb7c
children a3c6479c87ef
rev   line source
kaf24@6714 1 #ifndef __SCHED_H__
kaf24@6714 2 #define __SCHED_H__
kaf24@6714 3
kaf24@6714 4 #include <list.h>
kfraser@12473 5 #include <time.h>
kaf24@6714 6
kaf24@6714 7 struct thread
kaf24@6714 8 {
kaf24@6714 9 char *name;
kaf24@6714 10 char *stack;
kaf24@9911 11 unsigned long sp; /* Stack pointer */
kaf24@9911 12 unsigned long ip; /* Instruction pointer */
kaf24@6714 13 struct list_head thread_list;
kaf24@6714 14 u32 flags;
kfraser@12473 15 s_time_t wakeup_time;
kaf24@6714 16 };
kaf24@6714 17
kaf24@6714 18
kaf24@6714 19
kaf24@6714 20 void init_sched(void);
kaf24@6714 21 void run_idle_thread(void);
kaf24@6714 22 struct thread* create_thread(char *name, void (*function)(void *), void *data);
kaf24@6714 23 void schedule(void);
kaf24@6714 24
kaf24@6714 25 static inline struct thread* get_current(void)
kaf24@6714 26 {
kaf24@6714 27 struct thread **current;
kaf24@6714 28 #ifdef __i386__
kaf24@6714 29 __asm__("andl %%esp,%0; ":"=r" (current) : "r" (~8191UL));
kaf24@9911 30 #else
kaf24@9911 31 __asm__("andq %%rsp,%0; ":"=r" (current) : "r" (~8191UL));
kaf24@9911 32 #endif
kaf24@6714 33 return *current;
kaf24@6714 34 }
kaf24@6714 35
kaf24@6714 36 #define current get_current()
kaf24@6714 37
kaf24@6714 38
kaf24@6714 39 void wake(struct thread *thread);
kaf24@6714 40 void block(struct thread *thread);
kfraser@12473 41 void sleep(u32 millisecs);
kaf24@6714 42
kaf24@6714 43 #endif /* __SCHED_H__ */