文件名称:readerwriter
介绍说明--下载内容均来自于网络,请自行研究使用
实验一 用信号量来实现读者-写者问题
(一) 实验目的
理解进程(或线程)及信号量的概念
(二) 实验内容
1、定义一个数据缓存buffer及用于实现同步互斥的信号量。
2、定义一个读者函数:
当有写者在占用buffer时,读者应该等待,直到写者不再使用该buffer。
当有其他读者在占用buffer时,读者可对buffer进行读取操作。
当buffer中有数据时,则从其中读取一个数据,并显示然后退出。
当buffer中没有数据时,应等待,直到buffer中有数据可读。
3、定义一个写者函数
当有读者在占用buffer时,写者应该等待,直到所有的读者都退出为止。
当有其他写者占用buffer时,该写者应该等待,直到占用buffer的写者退出为止。
当buffer有空闲时,写者应该在buffer中写入一个数据并退出。
当buffer满时,写者应该等待,直到buffer有空闲为止。
4、定义主函数,在其中可以任意创建读者与写者。
可根据用户输入创建读者或写者进程(线程)。
5、用户界面
(三) 实验要求
在实验过程中,显示详细的各进程(线程)的状态及buffer使用情况。
(四) 实验学时 3-Experiments using semaphore to implement a reader- writer problem
(A) purpose of the experiment
Understand the process (or thread), and the concept of semaphore
(b) of the experiment content
1, define a data cache buffer, and synchronization for mutual exclusion semaphore.
2, the definition of a reader function:
When a write buffer in the occupation, the reader should wait until the writer is no longer used in the buffer.
When there are other readers in the occupied buffer, the reader can read buffer operations.
When the buffer has data, from which a data read and displayed and then exit.
When the buffer contains no data, they should wait until the buffer has data to read.
3, define the function of a writer
When a reader occupied buffer, the writer should wait until all of the readers exit.
When the buffer occupied by other writers, the writer should wait until the write buffer occupied by exit.
When the buffer in their free time to write should be written in a
(一) 实验目的
理解进程(或线程)及信号量的概念
(二) 实验内容
1、定义一个数据缓存buffer及用于实现同步互斥的信号量。
2、定义一个读者函数:
当有写者在占用buffer时,读者应该等待,直到写者不再使用该buffer。
当有其他读者在占用buffer时,读者可对buffer进行读取操作。
当buffer中有数据时,则从其中读取一个数据,并显示然后退出。
当buffer中没有数据时,应等待,直到buffer中有数据可读。
3、定义一个写者函数
当有读者在占用buffer时,写者应该等待,直到所有的读者都退出为止。
当有其他写者占用buffer时,该写者应该等待,直到占用buffer的写者退出为止。
当buffer有空闲时,写者应该在buffer中写入一个数据并退出。
当buffer满时,写者应该等待,直到buffer有空闲为止。
4、定义主函数,在其中可以任意创建读者与写者。
可根据用户输入创建读者或写者进程(线程)。
5、用户界面
(三) 实验要求
在实验过程中,显示详细的各进程(线程)的状态及buffer使用情况。
(四) 实验学时 3-Experiments using semaphore to implement a reader- writer problem
(A) purpose of the experiment
Understand the process (or thread), and the concept of semaphore
(b) of the experiment content
1, define a data cache buffer, and synchronization for mutual exclusion semaphore.
2, the definition of a reader function:
When a write buffer in the occupation, the reader should wait until the writer is no longer used in the buffer.
When there are other readers in the occupied buffer, the reader can read buffer operations.
When the buffer has data, from which a data read and displayed and then exit.
When the buffer contains no data, they should wait until the buffer has data to read.
3, define the function of a writer
When a reader occupied buffer, the writer should wait until all of the readers exit.
When the buffer occupied by other writers, the writer should wait until the write buffer occupied by exit.
When the buffer in their free time to write should be written in a
(系统自动生成,下载前可以参看下载内容)
下载文件列表
瀹為獙涓