C线程代业代写代调试、POSIX Threads代编码

C线程代业代写代调试、POSIX Threads代编码
(CSCI 363) Project Two -- POSIX Threads
Instructions
This program sorts strings using "enzymes". An enzyme is a function that sorts two consecutive
characters. We define one enzyme per pair of consecutive characters; these enzymes working
together in parallel can sort the entire string. We use pthreads to instantiate and parallelize the
enzymes.
Unfortunately, this program doesn't seem to be working correctly. That's where you come in.
Before you edit the code, read through it, and answer these questions:
1) Briefly explain why this application would be difficult to write using multiple processes
instead of threads.
2) What is the significance of 'workperformed'? How is it used?
3) Explain exactly what is the type of 'fp' in the following declaration: void *(*fp)(void *)
Now, to fix the program:
1) The function run_enzyme() needs to be created. Please see the notes inside enzyme.c.
2) The function 'make_enzyme_threads' has a memory bug. Fix this by simply re-ordering the
lines in this function. It is simple fix but may take a while for you to find it.
3) The function 'join_on_enzymes' is incomplete. Read the relevant man pages and figure out
how the function is supposed to work. Then insert the correct code snippets into
'whatgoeshere'.
4) Your programming work can be considered complete when you have completed the above
and all of the tests pass.
Testing
make test
./enzyme -test -f0 all
Running tests...
1.make ::pass
2.sort ::pass
3.pleasequit1 ::pass
4.pleasequit0 ::pass
5.swap1 ::pass
6.swap2 ::pass
7.swap3 ::pass
8.run_enzyme ::pass
9.join ::pass
10.cancel ::pass
You may also want to experiment with the cancel function -
./enzyme Cba
./enzyme CBA
Questions
1) Why do we not detach any of the enzyme threads? Would the program function if we
detached the sleeper thread?
2) Why does the program use sched_yield? What happens if this is not used? Will the swap
counts always be identical?
3) Threads are cancelled if the string contains a 'C' e.g. "Cherub". Why do we not include
cancelled threads when adding up the total number of swaps?
4) What happens when a thread tries to join itself? (You may need to create a test program to
try this) Does it deadlock? Or does it generate an error?
5) Briefly explain how the sleeper thread is implemented.
6) Briefly explain why PTHREAD_CANCEL_ASYNCHRONOUS is used in this MP.
7) Briefly explain the bug in #2 of fix the program section above.
Turn In
Enzyme.c (i.e. finish fix the program section tasks) and YourName.docx (i.e. answer the
questions above). Due date will be announced on Blackboard.
http://www.daixie0.com/contents/13/1306.html

我们的方向领域:window编程 数值算法 AI人工智能 金融统计 计量分析 大数据 网络编程 WEB编程 通讯编程 游戏编程多媒体linux 外挂编程 程序API图像处理 嵌入式/单片机 数据库编程 控制台 进程与线程 网络安全  汇编语言 硬件编程 软件设计 工程标准规等。其中代写代做编程语言或工具包括但不限于以下范围:

C/C++/C#代写

Java代写

IT代写

Python代写

辅导编程作业

Matlab代写

Haskell代写

Processing代写

Linux环境搭建

Rust代写

Data Structure Assginment 数据结构代写

MIPS代写

Machine Learning 作业 代写

Oracle/SQL/PostgreSQL/Pig 数据库代写/代做/辅导

Web开发、网站开发、网站作业

ASP.NET网站开发

Finance Insurace Statistics统计、回归、迭代

Prolog代写

Computer Computational method代做

因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:[email protected]

微信:codinghelp

猜你喜欢

转载自www.cnblogs.com/rrrrrrrrr/p/8974713.html