CS 284 Operating Systems
Programming Assignment #6
Due: 2/16/2001 - Class Time
Write a C program that produces enough neatly formatted out to demonstrate
that it has correctly performed the following:
-
signal(SIGALRM,SIG_IGN);
-
ignore the alarm notification
-
HP probably doesn't need this
-
initialize the random number generator
-
create a dynamic array named delay of 20 longs
-
create an array of thread_t to hold 20 thread IDs
-
create 20 threads each running the same function - named whatever you want
-
pass to the thread a random number % 3,000,000 via delay[i]
-
each thread gets the address of a different element of the dynamic array
-
after the 20 threads have been created
-
join each exiting thread reporting for each thread
-
the ID of the thread just joined
-
the value returned by that thread
-
when all threads have exit-ed
The function that all the threads are executing should
-
printf the fact that it's alive and how long it has been asked to sleep
-
usleep(the argument that it was passed)
-
return the argument that it was passed
Sample Output - Please don't duplicate.
It's being shown to clarify the assignment. OK?
footnotes:
-
pthread's join doesn't report back the thread ID so users of pthreads will
have to improvise
-
ps -fL
-
reported that my process began with 4 kernel LWPs and after creating all
the threads I had been assigned as many as 20 kernel LWPs (without my requesting)
=================================================================
You will use the 'script' command to capture all necessary information
for handin.