Find Jobs
Hire Freelancers

Processes, Inter-Process Communication, and Concurrency

$30-5000 USD

已关闭
已发布超过 15 年前

$30-5000 USD

货到付款
Assignment 1 Processes, Inter-Process Communication, and Concurrency *Due September 16th midnight* **Summary** In this assignment, you will create two versions of a simple multi-process game : one without and another with inter-process synchronization. You will also measure the relative performance of the two versions of your multi-process game. **Objectives** Learn how to create and terminate processes. Learn use of inter-process communication using shared memory, semaphores, signals, etc. Learn the basic workings of CPU scheduling code in Linux. ** ** ## Deliverables Assignment 1 Processes, Inter-Process Communication, and Concurrency *Due September 16th midnight* **Summary** In this assignment, you will create two versions of a simple multi-process game : one without and another with inter-process synchronization. You will also measure the relative performance of the two versions of your multi-process game. **Objectives** Learn how to create and terminate processes. Learn use of inter-process communication using shared memory, semaphores, signals, etc. Learn the basic workings of CPU scheduling code in Linux. **Part A: Multi-Process Game of Turns** In this part, you are asked to write a simple program that takes two command-line arguments **P** and **N**. The main process creates **P** other child processes, waits for all of them to complete, and then exits. All the child processes form one logical ring among each other. (In rest of the description, the term "process" refers to a "child process".) For example, if the processes are numbered 1 to P, then The next neighbor of process 1 is process 2, The next neighbor of process i is process i+1 for all i < P , and The next neighbor of process P is process 1, which completes a ring among the processes. Assume that a *shared* integer variable, called turn, identifies the number of the processes whose turn it is at any instant. A second *process-local* variable in each process, called me, identifies the identity of each process (i.e. each process stores its own identity in a per-process local variable me). A third per-process *local* variable, called next, identifies the next process in the ring. The processes sequentially pass the turns among each other in the logical ring. When each process gets its turn, it increments another shared variable called counter. The pseudo-code within each process for passing turns might look something as follows. (Note: Replace turn and counter below with appropriate ways of accessing data within shared memory regions). while(turn != me ) /* do nothing - just busy loop*/ ; /* got my turn - increment counter */ counter = counter + 1; /* give the turn to next process */ turn = next; The program terminates when the each process has received N turns. In the above description, several programming details have been omitted for you to figure out. This includes Creating P child processes from main process. Constructing the logical ring among child processes. Initializing each child process's identity in the me variable. Initializing each child process' next neighbor in the next variable. Initializing the shared memory region and the shared data values. Have the main process wait for child processes to complete N turns before exiting. **Part B: More Efficient Game of Turns** You might notice that the program you wrote in Part A is inefficient because each process *busy loops* till the CPU scheduler kicks it out (after its time-slice is over) and allows another process to execute and make progress. (Does the program in Part A have a race condition? Why or why not?) What we ideally want is that each process should be given control of the CPU only when it is that process' turn. Modify the program you wrote in Part A (using appropriate synchronization mechanisms) such that ***each process gets to run (i.e., gets control of the CPU) only when it is that process's turn, and at no other time.*** Again, you would need to work out the programming details of how and where to use inter-process synchronization. **Part C: Profiling the Game of Turns** In this part, you are asked to write user-level profiling code in order to measure the performance of the two versions of programs you wrote in Part A and Part B. Use a combination of gettimeofday() system call and inter-process synchronization to measure (1) the average hand-over time between two consecutive processes in the ring and (b) the total execution time to complete N turns. Plot the measured values as graphs when varying number of processes P and number of turns N. Explain the results you obtain. **Submission Guidelines** Submit all your code files as ONE tarred-gzipped file (.tgz file) on the blackboard. DO NOT SUBMIT EACH FILE INDIVIDUALLY. Make one .tgz file. Check the submission guidelines on course web page for how to prepare a .tgz file. Also submit a report, either in PDF or DOC format, explaining the results from Part C. Bring your report with you at the demonstration time that you signed up for. ## Platform unix,linux,
项目 ID: 3229665

关于此项目

3提案
远程项目
活跃16 年前

想赚点钱吗?

在Freelancer上竞价的好处

设定您的预算和时间范围
为您的工作获得报酬
简要概述您的提案
免费注册和竞标工作
3威客以平均价$93 USD来参与此工作竞价
用户头像
See private message.
$68 USD 在2天之内
5.0 (56条评论)
5.7
5.7
用户头像
See private message.
$127.50 USD 在2天之内
0.0 (0条评论)
0.0
0.0
用户头像
See private message.
$84.15 USD 在2天之内
0.0 (0条评论)
0.0
0.0

关于客户

UNITED STATES的国旗
United States
0.0
0
会员自9月 16, 2008起

客户认证

谢谢!我们已通过电子邮件向您发送了索取免费积分的链接。
发送电子邮件时出现问题。请再试一次。
已注册用户 发布工作总数
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
加载预览
授予地理位置权限。
您的登录会话已过期而且您已经登出,请再次登录。