annotate TaskManager/kernel/ppe/Sem.h @ 1531:4443d59a8210 draft

SDL.h in main.cc
author yuhi@cr.ie.u-ryukyu.ac.jp
date Fri, 07 Dec 2012 15:46:27 +0900
parents 4c209dd223cd
children f73ca57cdc81
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1180
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
1 #ifndef INCLUDED_SEM
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
2 #define INCLUDED_SEM
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
3
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
4 #include <pthread.h>
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
5
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
6 typedef struct sem_t {
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
7 volatile int value; //セマフォ変数
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
8 pthread_mutex_t mutex; //セマフォ操作用のロック
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
9 pthread_cond_t cond; //待ち合わせ用の条件変数
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
10 } sem_t, *sem_ptr;
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
11
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
12 class Sem {
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
13 public:
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
14 /* constructor */
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
15 Sem(int value);
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
16 ~Sem();
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
17 void sem_p();
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
18 void sem_v();
1186
4c209dd223cd fix MailManager and Semaphore
Daichi TOMA
parents: 1180
diff changeset
19 int count();
1180
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
20 /* variables */
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
21 private:
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
22 sem_t *sem;
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
23 };
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
24
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
25 typedef Sem *SemPtr;
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
26
2e20d2bb55c6 change mailmanager to mail on semaphore
Daichi TOMA
parents:
diff changeset
27 #endif /* INCLUDED_SEM */