In this lab you have to write a simple scheduler that executes a
sequence of tasks and handle exceptions that may occur while executing
these tasks. The tasks to be executed are passed as argument to the
scheduler using an array of function pointers.
Some of the tasks may run in an infinite loop while others may throw
exceptions like segmentation fault.
tar -xpvf lab08.tar
my_scheduler.h
,
my_scheduler.c
and main.c
. It also contains a Makefile
that you should
use for compiling.my_scheduler.c
.
We will replace main.c
with our own main.c
to grade the project. You should use the same function prototypes as
specified in my_scheduler.h
.
Implement the following functionality:Function name |
Functionality |
void scheduler(void
(*func[])(), int len); |
Schedules multiple
tasks one after the other. These tasks are supplied as the func
argument (array of function pointers) to the scheduler. The scheduler
runs in an infinite loop scheduling the tasks in a round robin manner.
The len argument specifies the number of tasks in the array of function
pointers. |
void handle_signal(int
signo); |
Defines the behavior of
handler when a signal is received. This is supposed to handle 4 kinds
of signals: SIGINT, SIGFPE, SIGSEGV, SIGALRM. In case of SIGINT, the
handler prints a message and exits. For the other three signals, you
need to print a message and return the control back to the scheduler.
(Hint: Use longjmp) The following messages are printed for various signals: For SIGINT: SIG:
Interrupt received. Exiting For SIGFPE: SIG: Floating
point exception encountered For SIGSEGV: SIG:
Segmentation fault encountered For SIGALRM: SIG: Alarm
went off! Note: some signals are reset to default after each call. You will need to reset the signal handler each time. |
void initHandlers(); |
Initializes the signal
handling. That is, for each of the signals SIGINT, SIGFPE, SIGSEGV and
SIGALRM, it sets up signal handling by specifying the handle_signal(int
signo) as the handler function. |
scheduler.ref
can be executed
to see the
expected behavior of the scheduler.
Before you submit make sure to test your implementation on LORE
using the Makefile
provided.
Your code must compile using the provided Makefile
and
run on LORE for you to earn points for this lab.
Type cd .. in lab08 and change working directory to the parent directory of lab08.
In the parent directory of lab08, type turnin -v -c cs240=XXX -p lab08 lab08 to turnin your work. Replace XXX with your section number.
9:30 am - 11:20 am F | F930 |
11:30 am - 1:20 pm F | F1130 |
1:30 pm - 3:20 pm F | F130 |
3:30 pm - 5:20 pm F | F330 |
9:30 am - 11:20 am R | R930 |
11:30 am - 1:20 pm R | R1130 |
3:30 pm - 5:20 pm R | R330 |
11:30 am - 1:20 pm T | T1130 |
Now, you may use the command, turnin -c cs240=XXX -p lab08 -v to verify your submission.
This lab is due on Monday, April 25 by 11:59 pm