aboutsummaryrefslogtreecommitdiffstats
path: root/extras/mini-os/sched.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-02-12 14:35:39 +0000
committerKeir Fraser <keir.fraser@citrix.com>2008-02-12 14:35:39 +0000
commit0243b256d6187ea610174531607366945e489605 (patch)
treefd2de9267b7493642626f8c84d7c81ebcd336bed /extras/mini-os/sched.c
parent67bfbd67d1311a1a590b47e568a07622d4492873 (diff)
downloadxen-0243b256d6187ea610174531607366945e489605.tar.gz
xen-0243b256d6187ea610174531607366945e489605.tar.bz2
xen-0243b256d6187ea610174531607366945e489605.zip
Add stubdomain support. See stubdom/README for usage details.
- Move PAGE_SIZE and STACK_SIZE into __PAGE_SIZE and __STACK_SIZE in arch_limits.h so as to permit getting them from there without pulling all the internal Mini-OS defines. - Setup a xen-elf cross-compilation environment in stubdom/cross-root - Add a POSIX layer on top of Mini-OS by linking against the newlib C library and lwIP, and implementing the Unixish part in mini-os/lib/sys.c - Cross-compile zlib and libpci too. - Add an xs.h-compatible layer on top of Mini-OS' xenbus. - Cross-compile libxc with an additional xc_minios.c and a few things disabled. - Cross-compile ioemu with an additional block-vbd, but without sound, tpm and other details. A few hacks are needed: - Align ide and scsi buffers at least on sector size to permit direct transmission to the block backend. While we are at it, just page-align it to possibly save a segment. Also, limit the scsi buffer size because of limitations of the block paravirtualization protocol. - Allocate big tables dynamically rather that letting them go to bss: when Mini-OS gets installed in memory, bss is not lazily allocated, and doing so during Mini-OS is unnecessarily trick while we can simply use malloc. - Had to change the Mini-OS compilation somehow, so as to export Mini-OS compilation flags to the Makefiles of libxc and ioemu. Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
Diffstat (limited to 'extras/mini-os/sched.c')
-rw-r--r--extras/mini-os/sched.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/extras/mini-os/sched.c b/extras/mini-os/sched.c
index 18b3f01538..19a102f056 100644
--- a/extras/mini-os/sched.c
+++ b/extras/mini-os/sched.c
@@ -56,6 +56,7 @@
struct thread *idle_thread = NULL;
LIST_HEAD(exited_threads);
+static int threads_started;
void inline print_runqueue(void)
{
@@ -172,6 +173,9 @@ struct thread* create_thread(char *name, void (*function)(void *), void *data)
/* Not runable, not exited, not sleeping */
thread->flags = 0;
thread->wakeup_time = 0LL;
+#ifdef HAVE_LIBC
+ _REENT_INIT_PTR((&thread->reent))
+#endif
set_runnable(thread);
local_irq_save(flags);
if(idle_thread != NULL) {
@@ -185,6 +189,42 @@ struct thread* create_thread(char *name, void (*function)(void *), void *data)
return thread;
}
+#ifdef HAVE_LIBC
+static struct _reent callback_reent;
+struct _reent *__getreent(void)
+{
+ struct _reent *_reent;
+
+ if (!threads_started)
+ _reent = _impure_ptr;
+ else if (in_callback)
+ _reent = &callback_reent;
+ else
+ _reent = &get_current()->reent;
+
+#ifndef NDEBUG
+#if defined(__x86_64__) || defined(__x86__)
+ {
+#ifdef __x86_64__
+ register unsigned long sp asm ("rsp");
+#else
+ register unsigned long sp asm ("esp");
+#endif
+ if ((sp & (STACK_SIZE-1)) < STACK_SIZE / 16) {
+ static int overflowing;
+ if (!overflowing) {
+ overflowing = 1;
+ printk("stack overflow\n");
+ BUG();
+ }
+ }
+ }
+#endif
+#endif
+ return _reent;
+}
+#endif
+
void exit_thread(void)
{
unsigned long flags;
@@ -228,6 +268,7 @@ void wake(struct thread *thread)
void idle_thread_fn(void *unused)
{
s_time_t until;
+ threads_started = 1;
unsigned long flags;
struct list_head *iterator;
struct thread *next, *thread;
@@ -297,6 +338,9 @@ void init_sched(void)
{
printk("Initialising scheduler\n");
+#ifdef HAVE_LIBC
+ _REENT_INIT_PTR((&callback_reent))
+#endif
idle_thread = create_thread("Idle", idle_thread_fn, NULL);
INIT_LIST_HEAD(&idle_thread->thread_list);
}