2018-04-29

南昌大学实验报告

姓名:王梦佳

学号:6103115097

邮箱地址:[email protected]

专业班级:计科153班

实验日期:2018.4.30

课程名称:LINUX程序设计

实验项目名称

Lab 4: Multi-processing in Linux

实验目的

• Understanding the mechanism of multi-processing
• Understanding the idea of process scheduling
• Understanding multi-thread programming

实验步骤

The Fork Question
Fork and fork more
The Collatz conjecture
进程是资源管理的最小单位,而线程是程序执行的最小单位。

实验数据或结果

Determine what will be output at the commented lines LINE X and LINE Y
for fork_problem.c

makefile文件内容:


makefile.png

frork-problem的结果:


fork.png

• How many unique processes are created using the multi-fork?
three

Complete the code for function fork1 in fork1.c
Complete the code for function fork2 in fork2.c

完善文件内容:


fork-complete.png

Compile both and run them

fork1的结果:


fork1-result.png

fork2的结果:


fork2-result.png

Collatz问题:
Collatz.c直接运行的结果:


collatz.png

运用链表和多线程后的thrd-Collatz.c的运行结果:


thrd-Collatz.png

参考资料

https://www.jianshu.com/

你可能感兴趣的:(2018-04-29)