-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassignmentOS.c
More file actions
39 lines (34 loc) · 844 Bytes
/
Copy pathassignmentOS.c
File metadata and controls
39 lines (34 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Name: Ahmad Abid
// Rollno: 55 Batch: 23
#include<pthread.h>
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
void *DingDong(void *arg)
{
printf("Ding\n");
}
void *DongDing(void *arg)
{
//sleep(1);
printf("Dong\n");
}
int main()
{
pthread_t id1, id2;
long var1, var2;
for(int counter=1; counter < 5; counter++)
{
var1 = pthread_create(&id1, NULL, &DingDong, (void *) &counter);
if(var1 !=0)
{
printf("Thread not created successfully for Ding Dong.\n");
}
var2 = pthread_create(&id2, NULL, &DongDing, (void *) &counter);
if(var2 !=0)
{
printf("Thread not created successfully for Dong Ding.\n");
}
}
pthread_exit(NULL);
}