Specify an mbox type when getting an event queue
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 12 Aug 2015 22:33:32 +0000 (18:33 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 28 Sep 2015 19:14:00 +0000 (15:14 -0400)
This common helper allocates an event queue and initializes the mailbox.
As a stopgap, I was assuming it was a UCQ.  Let's let the caller decide.

Note that the thread0 scheduler doesn't actually need a UCQ.  It knows
what thread unblocked.  There probably are other testing functions that
don't care about UCQs vs bits, but it's not worth messing with them.

tests/alarm.c
tests/evq_block.c
tests/mhello.c
user/benchutil/alarm.c
user/parlib/event.c
user/parlib/include/event.h
user/parlib/signal.c
user/parlib/thread0_sched.c

index 8d6204f..44e0c2a 100644 (file)
@@ -62,7 +62,7 @@ int main(int argc, char **argv)
        /* Since we're doing SPAM_PUBLIC later, we actually don't need a big ev_q.
         * But someone might copy/paste this and change a flag. */
        register_ev_handler(EV_ALARM, handle_alarm, 0);
-       if (!(ev_q = get_big_event_q())) {
+       if (!(ev_q = get_big_event_q(EV_MBOX_UCQ))) {
                perror("Failed ev_q");  /* it'll actually PF if malloc fails */
                exit(-1);
        }
index 4d2df75..3a97b99 100644 (file)
@@ -13,7 +13,7 @@
 
 static struct event_queue *get_ectlr_evq(void)
 {
-       struct event_queue *ev_q = get_big_event_q();
+       struct event_queue *ev_q = get_big_event_q(EV_MBOX_UCQ);
        evq_attach_wakeup_ctlr(ev_q);
        return ev_q;
 }
index ee1566c..a0c1bce 100644 (file)
@@ -48,7 +48,7 @@ int main(int argc, char** argv)
        assert(!in_vcore_context());
        
        /* prep indirect ev_q.  Note we grab a big one */
-       indirect_q = get_big_event_q();
+       indirect_q = get_big_event_q(EV_MBOX_UCQ);
        indirect_q->ev_flags = EVENT_IPI;
        indirect_q->ev_vcore = 1;                       /* IPI core 1 */
        indirect_q->ev_handler = 0;
index ec15660..e20909f 100644 (file)
@@ -168,7 +168,7 @@ static void init_alarm_service(void)
        /* Since we're doing SPAM_PUBLIC later, we actually don't need a big ev_q.
         * But someone might copy/paste this and change a flag. */
        register_ev_handler(EV_ALARM, handle_user_alarm, 0);
-       if (!(ev_q = get_big_event_q())) {
+       if (!(ev_q = get_big_event_q(EV_MBOX_UCQ))) {
                perror("Useralarm: Failed ev_q");
                return;
        }
index b113096..f565d1e 100644 (file)
@@ -50,10 +50,10 @@ struct event_queue *get_big_event_q_raw(void)
        return (struct event_queue*)big_q;
 }
 
-struct event_queue *get_big_event_q(void)
+struct event_queue *get_big_event_q(int mbox_type)
 {
        struct event_queue *big_q = get_big_event_q_raw();
-       event_mbox_init(big_q->ev_mbox, EV_MBOX_UCQ);
+       event_mbox_init(big_q->ev_mbox, mbox_type);
        return big_q;
 }
 
index 3b4b1eb..23f765b 100644 (file)
@@ -16,7 +16,7 @@ __BEGIN_DECLS
 
 /********* Event_q Setup / Registration  ***********/
 struct event_queue *get_big_event_q_raw(void);
-struct event_queue *get_big_event_q(void);
+struct event_queue *get_big_event_q(int mbox_type);
 void event_mbox_init(struct event_mbox *ev_mbox, int mbox_type);
 void put_big_event_q_raw(struct event_queue *ev_q);
 void put_big_event_q(struct event_queue *ev_q);
index 4be0672..2e661dd 100644 (file)
@@ -225,7 +225,7 @@ void init_posix_signals(void)
 {
        struct event_queue *posix_sig_ev_q;
        register_ev_handler(EV_POSIX_SIGNAL, handle_event, 0);
-       posix_sig_ev_q = get_big_event_q();
+       posix_sig_ev_q = get_big_event_q(EV_MBOX_UCQ);
        assert(posix_sig_ev_q);
        posix_sig_ev_q->ev_flags = EVENT_IPI | EVENT_INDIR | EVENT_SPAM_INDIR |
                                   EVENT_WAKEUP;
index 3ae38d4..a2d61af 100644 (file)
@@ -53,7 +53,8 @@ static void thread0_handle_syscall(struct event_msg *ev_msg,
 void thread0_lib_init(void)
 {
        memset(&thread0_info, 0, sizeof(thread0_info));
-       sysc_evq = get_big_event_q();
+       /* we don't care about the message, so don't bother with a UCQ */
+       sysc_evq = get_big_event_q(EV_MBOX_BITMAP);
        sysc_evq->ev_flags = EVENT_INDIR | EVENT_WAKEUP;
        register_ev_handler(EV_SYSCALL, thread0_handle_syscall, 0);
 }