BCQ touch-ups (XCC)
authorBarret Rhoden <brho@cs.berkeley.edu>
Thu, 23 Oct 2014 19:42:43 +0000 (12:42 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 2 Dec 2014 22:57:07 +0000 (14:57 -0800)
Weren't memsetting the entire structure, and I wasted an hour or so
debugging a BCQ with a non-power-of-2 number of elements.

Reinstall your kernel headers.

kern/include/ros/bcq.h
kern/src/process.c

index 71214d9..3711c97 100644 (file)
@@ -111,7 +111,10 @@ struct bcq_header {
 
 /* Functions */                                                                
 #define bcq_init(_bcq, _ele_type, _num_elems)                                  \
-       memset((_bcq), 0, sizeof( _ele_type ) * (_num_elems))                                 
+({                                                                             \
+       memset((_bcq), 0, sizeof(*(_bcq)));                                        \
+       assert((_num_elems) == ROUNDUPPWR2(_num_elems));                           \
+})
 
 /* Num empty buffer slots in the BCQ */
 #define BCQ_FREE_SLOTS(_p, _cp, _ne) ((_ne) - ((_p) - (_cp)))
@@ -149,6 +152,7 @@ struct bcq_header {
        if (!__retval) {                                                           \
                /* from here out, __prod is the local __prod that we won */            \
                (_bcq)->wraps[__prod & ((_num_elems)-1)].elem = *(_elem);              \
+               wmb();                                                                 \
                (_bcq)->wraps[__prod & ((_num_elems)-1)].rdy_for_cons = TRUE;          \
        }                                                                          \
        __retval;                                                                  \
@@ -190,4 +194,7 @@ struct bcq_header {
 #define bcq_empty(_bcq)                                                        \
        BCQ_NO_WORK((_bcq)->hdr.prod_idx, (_bcq)->hdr.cons_pvt_idx)
 
+#define bcq_nr_full(_bcq)                                                      \
+       ((_bcq)->hdr.prod_idx - (_bcq)->hdr.cons_pub_idx)
+
 #endif /* ROS_INC_BCQ_H */
index f2da1c4..68a42e6 100644 (file)
@@ -6,7 +6,6 @@
 #pragma nosharc
 #endif
 
-#include <ros/bcq.h>
 #include <event.h>
 #include <arch/arch.h>
 #include <bitmask.h>