Skip to contentSkip to conversation

MiniOS timeouts

PATCH In review Grzegorz Milos 2 participants 3 messages Nov 14, 2006 – Nov 15, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MiniOS timeouts

The patch adds timeouts to MiniOS threads. The patch is based on original patch by Robert Kaiser.

Keir could you apply please?

Also, Anil, do you still have problems with compiling MiniOS? It works, for me. I finally have time to deal with any problems you might have.

Cheers
Gregor

extras/mini-os/README +2 -2
diff -r 3cc0b589c235 -r 1facc5f0d408 extras/mini-os/README
@@ -26,5 +26,5 @@
 - to start it do the following in domain0 (assuming xend is running)
   # xm create domain_config
 
-this starts the kernel and prints out a bunch of stuff and then every
-1000 timer interrupts the system time.
+this starts the kernel and prints out a bunch of stuff and then once
+every second the system time.
extras/mini-os/include/sched.h +3 -0
diff -r 3cc0b589c235 -r 1facc5f0d408 extras/mini-os/include/sched.h
@@ -2,6 +2,7 @@
 #define __SCHED_H__
 
 #include <list.h>
+#include <time.h>
 
 struct thread
 {
@@ -11,6 +12,7 @@
     unsigned long ip;  /* Instruction pointer */
     struct list_head thread_list;
     u32 flags;
+    s_time_t wakeup_time;
 };
 
 
@@ -36,5 +38,6 @@
 
 void wake(struct thread *thread);
 void block(struct thread *thread);
+void sleep(u32 millisecs);
 
 #endif /* __SCHED_H__ */
extras/mini-os/include/time.h +4 -2
diff -r 3cc0b589c235 -r 1facc5f0d408 extras/mini-os/include/time.h
@@ -7,8 +7,9 @@
  *        File: time.h
  *      Author: Rolf Neugebauer ([email protected])
  *     Changes: Grzegorz Milos ([email protected])
+ *              Robert Kaiser ([email protected])
  *              
- *        Date: Jul 2003, changesJun 2005
+ *        Date: Jul 2003, changes: Jun 2005, Sep 2006
  * 
  * Environment: Xen Minimal OS
  * Description: Time and timer functions
@@ -57,7 +58,8 @@
 void     init_time(void);
 s_time_t get_s_time(void);
 s_time_t get_v_time(void);
+u64      monotonic_clock(void);
 void     gettimeofday(struct timeval *tv);
-void     block_domain(u32 millisecs);
+void     block_domain(s_time_t until);
 
 #endif /* _TIME_H_ */
extras/mini-os/kernel.c +14 -0
diff -r 3cc0b589c235 -r 1facc5f0d408 extras/mini-os/kernel.c
@@ -6,6 +6,7 @@
  * 
  * Copyright (c) 2002-2003, K A Fraser & R Neugebauer
  * Copyright (c) 2005, Grzegorz Milos, Intel Research Cambridge
+ * Copyright (c) 2006, Robert Kaiser, FH Wiesbaden
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to
@@ -66,11 +67,24 @@
     /* test_xenbus(); */
 }
 
+void periodic_thread(void *p)
+{
+    struct timeval tv;
+    printk("Periodic thread started.\n");
+    for(;;)
+    {
+        gettimeofday(&tv);
+        printk("T(s=%ld us=%ld)\n", tv.tv_sec, tv.tv_usec);
+        sleep(1000);
+    }
+}
+
 /* This should be overridden by the application we are linked against. */
 __attribute__((weak)) int app_main(start_info_t *si)
 {
     printk("Dummy main: start_info=%p\n", si);
     create_thread("xenbus_tester", xenbus_tester, si);
+    create_thread("periodic_thread", periodic_thread, si);
     return 0;
 }
 
extras/mini-os/sched.c +67 -4

115 lines not on this page · raw message

extras/mini-os/time.c +7 -19
diff -r 3cc0b589c235 -r 1facc5f0d408 extras/mini-os/time.c
@@ -3,6 +3,7 @@
  * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge
  * (C) 2002-2003 - Keir Fraser - University of Cambridge 
  * (C) 2005 - Grzegorz Milos - Intel Research Cambridge
+ * (C) 2006 - Robert Kaiser - FH Wiesbaden
  ****************************************************************************
  *
  *        File: time.c
@@ -194,21 +195,15 @@
 }
 
 
-static void print_current_time(void)
-{
-    struct timeval tv;    
-
-    gettimeofday(&tv);
-    printk("T(s=%ld us=%ld)\n", tv.tv_sec, tv.tv_usec);
-}
-
-
-void block_domain(u32 millisecs)
+void block_domain(s_time_t until)
 {
     struct timeval tv;
     gettimeofday(&tv);
-    HYPERVISOR_set_timer_op(monotonic_clock() + 1000000LL * (s64) millisecs);
-    HYPERVISOR_sched_op(SCHEDOP_block, 0);
+    if(monotonic_clock() < until)
+    {
+        HYPERVISOR_set_timer_op(until);
+        HYPERVISOR_sched_op(SCHEDOP_block, 0);
+    }
 }
 
 
@@ -217,15 +212,8 @@
  */
 static void timer_handler(evtchn_port_t ev, struct pt_regs *regs, void *ign)
 {
-    static int i;
-
     get_time_values_from_xen();
     update_wallclock();
-    i++;
-    if (i >= 1000) {
-        print_current_time();
-        i = 0;
-    }
 }
 
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 8 lines · Grzegorz Milos

The patch adds timeouts to MiniOS threads. The patch is based on original patch by Robert Kaiser.

Keir could you apply please?

Also, Anil, do you still have problems with compiling MiniOS? It works, for me. I finally have time to deal with any problems you might have.

MiniOS has been fine for me since I added the XEN_INTERFACE_VERSION to freeze the interface it uses; of course that means that it will slip behind unless we keep it up-to-date (e.g. still uses dom0_ops.h). Refreshing it to the latest would be worthwhile if you have a moment!

-anil

#2 lore raw
Quoted 1 line

MiniOS has been fine for me since I added the XEN_INTERFACE_VERSION to freeze the interface it uses; of course that means that it will slip behind unless we keep it up-to-date (e.g. still uses dom0_ops.h). Refreshing it to the latest would be worthwhile if you have a moment!

Ok, I'll have a look on that when I'm finished with Dietmar's patches.

Cheers
Gregor