



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A lab exercise for students in csce 351: operating system kernels course. The objective of the lab is to familiarize students with sigsetjmp and siglongjmp functions, debugging process with gdb, and timer signal in linux. Students will also lay the groundwork for programming assignment 1.
Typology: Lab Reports
1 / 7
This page cannot be seen from the preview
Don't miss anything!




#include <stdlib.h>
#include <stdio.h> #include <signal.h> #include <setjmp.h> #include <string.h>
int main(void) { sigjmp_buf buf_ptr; int retval; sigset_t sigmask; int testval = 100; char message[] = "Original Message"; if (sigsetjmp(buf_ptr,1) == 0) { fprintf (stderr,"1. message = %s, testval = %d\n", message, testval); strcpy (message, "New Message"); testval = 1000; fprintf (stderr,"2. message = %s, testval = %d\n", message, testval); } else { fprintf (stderr,"3. message = %s, testval = %d\n", message, testval); strcpy (message, "Newest Message"); testval = 10000; fprintf (stderr,"4. message = %s, testval = %d\n", message, testval); return; } siglongjmp(buf_ptr, 1); }
#include <stdlib.h> #include <stdio.h> #include <signal.h> #include <setjmp.h> #include <string.h>
void proc1(char*); sigjmp_buf buf_ptr1;
int main(void) { int retval; int count = 0; sigset_t sigmask; char message[] = "Original Message"; sigsetjmp(buf_ptr1,1); fprintf (stderr,"1. message = %s\n", message); if (count >= 4) return; count++; proc1(message); } void proc1(char* message) { strcpy (message, "New Message"); siglongjmp(buf_ptr1, 1); }
/* initialize timer to send signal every 300 ms */ clocktimer.it_value.tv_sec = 0; clocktimer.it_value.tv_usec = INTERVAL; clocktimer.it_interval.tv_sec = 0; clocktimer.it_interval.tv_usec = INTERVAL; setitimer (ITIMER_REAL, &clocktimer, &oldclocktimer); sigset (SIGALRM, signal_processor); producer(); }
void signal_processor( int signal ) { printf ("get a signal\n"); } void producer() { int i; while(1){ for (i = 0; i < 1000000; i++); printf ("Producer\n"); } }