A simple example for multithreading and semaphore
2016-08-23
0 0 0
no vote
Other
Earn points
This example implements a reading room model.
Suppose there are 8 seats in the reading room and 5 seats in the waiting room.
The readers' action will be like this:
1) A reader registers his information in the front desk before he enters the reading room. He logs out after he leaves. The front desk can only handle one reader at one time.
2) If a reader finds out the reading room is full, he will wait in the waiting room.
3) If there are not seats in the waiting room, he will leave.
*The main thread will start 20 reader threads. Reader threads will repeat the behavior mentioned above.
The behavior of the readers are recorded by printing in the screen and writing into a file.
c
线程
简单
一个
例子
信号
Related Source Codes
PClite
0
0
no vote
generic embeded FTP Client
0
0
no vote
UDP Test Demo
0
0
no vote
TMS320F28335 DSP transmits data to EEPROM through
0
0
no vote
TMS320F28335 CAN communication source code
0
0
no vote
No comment