![]() ![]() executable name (2) Semaphores synchronization implement Step 1: Assign the buffer pool owning n buffer as a shared resource. Use "Ctrl + Alt + T'" to open a terminal: Use gedit or vim command to open a text editor for encoding: "gedit file name.c" Compiler: "gcc filename.c-o executable name" (If you enter only gec filename.c, default executable program named a.out) When you use threaded libraries, gec compiler need to add -Ipthread Run the program. Experimental steps: (1) be familiar with multi-threaded programming under Ubuntu system. Experimental equipment (1) One PC per student, install Windows XP/2000 operating system (2) Personal PC installed VMware virtual machines and Ubuntu systems. When a producer is accessing the buffer, the consumer process can not access the buffer, so the buffer is mutually exclusive resources.ģ. Consumers get data from the buffer, and print the data. If successful in acquiring two forks, she eats for a while, then puts down the forks, and continues to think The second problem is to consider the n buffer pool as a shared resource, when the producer reads the data from the source - the file, the producer will apply for a data buffer, and it put the data into the buffer. When a philosopher gets sufficiently hungry, she tries to acquire her left and right forks, one at a time, in either order. The life of a philosopher consists of alternating periods of eating and thinking. The spaghetti is so slippery that a philosopher needs two forks to eat it. Each philosopher has a plate of spaghetti. Experimental Principle Five philosophers are seated around a circular table. Producer and consumer processes (or threads) have the same priority. Create a file as a data source, the file is written in advance. Create three processes (or threads) as producers, four processes (or threads) as a consumer. The second step is to implement the producer/ consumer problem. There is no deadlock at least continuous operation 30 times. The first step is to implement the dining philosophers problem and it requires displaying the operating status of each philosopher, such as eating, thinking. (2) Contents: It includes two parts: philosophers problem and producer/consumer problem. Experimental Contents and Objectives (1) Objectives: familiar with Linux and master the basic concepts about process and thread, process synchronization, and implements of two classic semaphore problems: dining philosophers problem and producer/consumer problem in Linux. c-o executable name" (If you enter only gec filename.c, default executable program named a.out) When you use threaded libraries, gcc compiler need to add -Ipthread Run the program: / executable nameġ. Guidence Use "Ctrl + Alt + T" to open a terminal Use gedit or vim command to open a text editor for encoding: "gedit file name. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |