
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
Material Type: Assignment; Professor: Ligatti; Class: Operating Systems; Subject: Computer Programming; University: University of South Florida; Term: Fall 2006;
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Due: Monday, September 18, 2006, at the beginning of class. Assignment description: Consider the multithreaded program below: #include <pthread.h> #include <stdio.h> #define N 2 void *printSi(void *threadid) { printf("%d: Si\n", threadid); pthread_exit(0); } int main (int argc, char *argv[]) { pthread_t threads[N]; pthread_attr_t attr[N]; int t; for(t=0; t<N; t++){ printf("Creating thread %d\n", t); pthread_attr_init(&attr[t]); pthread_create(&threads[t], &attr[t], printSi, (void *)t); } pthread_exit(0); } When N is 2, as above, there are three possible outputs from running this program: Creating thread 0 Creating thread 0 Creating thread 0 0: Si Creating thread 1 Creating thread 1 Creating thread 1 0: Si 1: Si 1: Si 1: Si 0: Si Question: In general, how many possible outputs are there for a given N? In other words, what is the function F(N) that returns the number of possible outputs for any positive integer N? (F(1) should equal 1, F(2) should equal 3, etc.) Simplify your answer as much as possible.