1. 程式人生 > >C線程代業代寫代調試、POSIX Threads代編碼

C線程代業代寫代調試、POSIX Threads代編碼

pthread window IE 通訊 ror follow swa help lac

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

C線程代業代寫代調試、POSIX Threads代編碼