































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
































#include <pthread.h> #include <stdio.h> int sum; /* this data is shared by the thread(s) */ void *runner(void param); / the thread / main(int argc, char argv[]) { pthread_t tidl, tid; / the thread identifier / pthread_attr_t attr; / set of thread attributes / if (argc != 2) { fprintf(stderr, ’’usage: a.out
/* The thread will begin control in this function */ void *runner(void *param) { int upper = atoi(param); int i; sum = 0; if (upper > 0) { for (i = 1; i <= upper; i++) sum += i; } pthread_exit(0); }
void echo()
{
chin = getchar(); chout = chin; putchar(chout);
}
Multiple Applications
invented to allow processing time to be shared among active applications
Structured Applications
extension of modular design and structured programming
Operating System Structure
OS themselves implemented as a set of processes or threads
are competing for use of the same resource
In the case of competing processes three control problems must be faced:
11
Figure 5.1 Illustration of Mutual Exclusion
Hardware support, as well