2010.01.28 A tip when testing - put all the waits in the background and use the jobs command for a list of the waits. 2010.01.28 Here are some code upgrades that are overdue - Use header files for my waitQ, eg, waitQ.h - Use the syscall macros to generate a proper well-typed syscall in the test programs. - Check that I have explicitly included all the header files for the kernel stuff I'm using in the code. - More robust testing. 2010.01.28 Here are some fixes I'll put into the next experiment. - test for 0 eventId in the kernel syscall code, not in the user eventWait and eventSig. - change the UNTERRUPTIBLE state to INTERRUPTIBLE so my control Z will work 2010.01.28 Several flaws in this code uncovered today in class. Here are some that I fixed. First I added #include because you should always explicitly include any header files that you need rather than relying on indirect inclusion (as via sched.h). Second, I got rid of the kmalloc for the wait queue heads. It wasn't necessary and there was a simple coding fix using the & address operator instead of declaring pointers that needed dynamic allocation. Sherri's advice from class - one should not use dynamic allocation in the kernel unless necessary. One should never use dynamic allocation if you have one of the following conditions. 1) you don't know exactly how big your space needs are 2) you don't know the contiguity requrements of the space 3) you can't afford to block. 4) you need to use a lock. Never kmalloc inside a lock. 2010.01.27 I have a couple of extra C programs in here to revive my use of command line arguments and command line Usage messages 2010.01.27 So this experiment does not actually allow for testing of unused event entries because I initialize all the event queue array entries with actual event Ids and event queues. This means I can do multiple pre-defined event queues, but I can't add or remove new events. I also don't test unused event entries, although that will probably work in this code. For example, I could modify this code to leave one of the event array entries with a 0 event Id indicating that there was no event queue associated with that event table entry. As long as the test calls did not ask to look for event 0 (the flag for unused event entries), then those entries will be skipped in searching for events. The next experiment 5 will introduce dynamic event creation and removal. 2010.01.27 Ok, so here's what happened. I had to switch to run-time init of my event queues because I had them in an array. I couldn't figure out how to use the static init macro that I used in experiment 3. I found a kernel function called init_eventqueue_head that I thought I could use to dynamically initialize the event queues in the array of events. I defined an event descriptor structure that had an eventId int and an event Queue. These structures were the entries in the event array. I put a loop in the module_init that initialized my event queue array with an event Id and a call to the kernel function init_eventqueue_head. The call to init_eventqueue_head gave me a pointer error. I reasoned that this was because the space was not allocated for the event_queue_head. The init_eventqueue_head expected to have uninitialized space already allocated. So I researched kmalloc and allocated the space and then called event_queue_head to initialize the event queues in a loop in the module_init function. That seemed to work. 2010.01.27 I had to switch to run-time init of the wait queues coded in module_init rather than using a static init macro as I did in experiment 3. 2010.01.27 Experiment 4 begins with experiment 3 but now sets up a set of kernel 3 event queues in an array rather than just one kernel event queue to hold waiting processes. I'll set MAX_QUEUE 4 and allocate all three queues at module init time, leaving one queue entry marked unused. I'll have no create or remove queue system calls. I'll change the wait and signal system calls and test programs to take one argument specifying the event number. I'll assume the event numbers are simply 1,2,3 for now. I'll reserve 0 to indicate an unused event table entry.