Module: xenomai-forge
Branch: master
Commit: e31aa37f2b85784a6f218570736ee09b5b3bbb68
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=e31aa37f2b85784a6f218570736ee09b5b3bbb68

Author: Philippe Gerum <r...@xenomai.org>
Date:   Tue Jul 16 10:10:44 2013 +0200

cobalt/posix/timer: allocate timer pool dynamically

Since users may have an awful lot of timers in some configurations,
don't charge the kernel bss for these, but rather get them from the
page allocator.

---

 kernel/cobalt/posix/timer.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/kernel/cobalt/posix/timer.c b/kernel/cobalt/posix/timer.c
index 2bd9231..7e79b50 100644
--- a/kernel/cobalt/posix/timer.c
+++ b/kernel/cobalt/posix/timer.c
@@ -40,7 +40,7 @@ struct cobalt_timer {
 
 static struct list_head timer_freeq;
 
-static struct cobalt_timer timer_pool[CONFIG_XENO_OPT_NRTIMERS];
+static struct cobalt_timer *timer_pool;
 
 static void timer_handler(struct xntimer *xntimer)
 {
@@ -596,10 +596,16 @@ out:
        xnlock_put_irqrestore(&nklock, s);
 }
 
+#define __TMPOOL_SIZE  (sizeof(struct cobalt_timer) * CONFIG_XENO_OPT_NRTIMERS)
+
 int cobalt_timer_pkg_init(void)
 {
        int n;
 
+       timer_pool = alloc_pages_exact(__TMPOOL_SIZE, GFP_KERNEL);
+       if (timer_pool == NULL)
+               return -ENOMEM;
+
        INIT_LIST_HEAD(&timer_freeq);
        INIT_LIST_HEAD(&cobalt_global_kqueues.timerq);
 
@@ -612,6 +618,7 @@ int cobalt_timer_pkg_init(void)
 void cobalt_timer_pkg_cleanup(void)
 {
        cobalt_timerq_cleanup(&cobalt_global_kqueues);
+       free_pages_exact(timer_pool, __TMPOOL_SIZE);
 }
 
 /*@}*/


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to