-
Notifications
You must be signed in to change notification settings - Fork 3
/
TEST1.c~
57 lines (40 loc) · 943 Bytes
/
TEST1.c~
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<stdio.h>
#include<stdlib.h>
#include<pthread.h>
#include<semaphore.h>
void *thread_function(void *arg);
sem_t semaphore;
void *thread_function( void *arg )
{
sem_wait( &semaphore );
int i,n,e,h,m,s,c,total=0;
scanf("%d",&n);
printf("Enter marks in 5 subjects");
for(i=0;i<n;i++){
scanf("En%d Hn%d Ma%d Sc%d Co%d",&e,&h,&m,&s,&c);
total = e+h+m+s+c;
if(total>=41){
grade ='A';
}else{
if(total>=31){
grade ='B';
}else{
if(total>=21){
grade='C';
}
}
}
grade;
sem_post( &semaphore );
}
pthread_exit( NULL );
}
main(){
int tmp;
tmp = sem_init( &semaphore, 0, 0 );
pthread_create( &thread[i], NULL, thread_function, NULL );
thread_function();
pthread_join( thread[i], NULL );
sem_destroy( &semaphore );
return 0;
}