ECEn 425

Lab #7: Event Flags


This lab is the final phase in the development of your YAK kernel. You are to add functions that create, pend on, set, and reset event flags so that you can correctly execute the application program lab7app.c without modification. You will also need the file lab7defs.h. You are expected to complete this lab with a partner.


You must add the following functions to your kernel. You should implement each function exactly according to the prototype given on the YAK Kernel webpage. Refer to that web page for additional details about these functions.

For this lab you will also need to change your tick and keyboard interrupt handlers. For the tick handler, you need not generate any output -- this makes your output much easier to read. You should replace the contents of your keyboard handler with the contents of sample function shown below.

void KeyboardHandler(void)
    char c;
    c = KeyBuffer;

    if(c == 'a') YKEventSet(charEvent, EVENT_A_KEY);
    else if(c == 'b') YKEventSet(charEvent, EVENT_B_KEY);
    else if(c == 'c') YKEventSet(charEvent, EVENT_C_KEY);
    else if(c == 'd') YKEventSet(charEvent, EVENT_A_KEY | EVENT_B_KEY | EVENT_C_KEY);
    else if(c == '1') YKEventSet(numEvent, EVENT_1_KEY);
    else if(c == '2') YKEventSet(numEvent, EVENT_2_KEY);
    else if(c == '3') YKEventSet(numEvent, EVENT_3_KEY);
    else {
        print("\nKEYPRESS (", 11);
        print(") IGNORED\n", 10);
You will also need to #include the header file lab7defs.h above your keyboard handler. This keyboard handler, in combination with the application code, will allow you to test the ability of your kernel to unblock one or multiple tasks in response to different events. Study the application code and keyboard handler carefully so that you understand what should happen when keys are pressed.


Implement the required functions and make sure that the application program runs correctly. As usual, the system should not crash when key presses occur in rapid succession, even with the timer tick frequency increased to 750 instructions per tick. For full credit, your application code must run correctly at this high tick rate, including the generation of all output for any combination of keypresses.

The behavior of the code depends on which keys are pressed. To verify that your kernel is running correctly, check the following functionality:

If other keys are pressed, the usual "KEYPRESS (X) IGNORED" should be displayed. No other text or error messages should be displayed.


When the kernel runs the application code correctly, show and demonstrate your code to a TA. Since you must demonstrate working code to a TA on or before the due date, please consider their lab schedule well in advance.

In addition to the demonstration, you must a written summary of problems you encountered, if any, in completing this lab. You should also include a report of the number of hours you spent on the lab, including coding and debugging. A realistic estimate is sufficient. Send a submission even if you didn't encounter any noteworthy bugs along the way. You will not receive full credit for the lab unless you send a report.

New for Fall 2019: we want both your report and your source code for the lab. The easiest way to do this is to create a report file (for consistency call it report.txt or report.pdf), to add it to the working directory for the lab, to create a compressed tar file (with all the files in your directory), and then to upload that file to Learning Suite.

To review, if 425/labx is your working directory for this lab, type the following in the 425 directory:

 tar -cvzf submission.tar.gz labx
and then upload the resulting compressed tar file (submission.tar.gz) to Learning Suite.

Important Notes

Debugging help

Here are comments from student reports describing their problems on this lab and how they tracked them down. As always, take them with a grain of salt.

Last updated 26 August 2019