Skip to content

Commit 7971354

Browse files
15h 30
Hy vọng là phiên bản cuối
1 parent ea325a2 commit 7971354

File tree

8 files changed

+4
-10
lines changed

8 files changed

+4
-10
lines changed

bai1

-112 Bytes
Binary file not shown.

bai1_sem

-200 Bytes
Binary file not shown.

bai2_sem

-195 Bytes
Binary file not shown.

bai2_sem.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,16 @@ int main()
6363
exit (0);
6464
}
6565
else{
66-
printf("Hello from process %d\n",i);
6766
if(i%2==0){
68-
//wait
69-
printf("P %d is waiting...\n",i);
7067
pthread_create(&t1,NULL,A1,NULL);
7168
pthread_join(t1, NULL);
7269
sem_post(sem1);
7370
sem_wait(sem2);
7471
pthread_create(&t2,NULL,A2,NULL);
7572
pthread_join(t2, NULL);
76-
77-
//sleep (1);
7873
} else{
7974
pthread_create(&t1,NULL,B1,NULL);
8075
pthread_join(t1, NULL);
81-
8276
sem_post(sem2);
8377
sem_wait(sem1);
8478
pthread_create(&t2,NULL,B2,NULL);

bai3

-241 Bytes
Binary file not shown.

bai3.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@
66

77
void* MakeH(void* arg) {
88
printf("H\n");
9-
pthread_exit(NULL);
109
}
1110

1211
void* MakeO(void* arg) {
1312
printf("O\n");
14-
pthread_exit(NULL);
1513
}
1614
void* MakeH2O(void* arg) {
1715
printf("=>H2O\n");
18-
pthread_exit(NULL);
1916
}
2017

2118
int main()
@@ -25,7 +22,6 @@ int main()
2522
pthread_create(&t1,NULL,MakeH,NULL);
2623
pthread_create(&t2,NULL,MakeO,NULL);
2724
pthread_create(&t3,NULL,MakeH2O,NULL);
28-
sleep(1);
2925
}
3026
return 0;
3127
}

bai3_sem

185 Bytes
Binary file not shown.

bai3_sem.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,7 @@ int main()
6767
}
6868

6969

70+
<<<<<<< Updated upstream
71+
=======
72+
73+
>>>>>>> Stashed changes

0 commit comments

Comments
 (0)