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

原文地址:https://www.cnblogs.com/rrrrrrrrr/p/8974713.html

时间: 2024-10-09 23:31:16

C线程代业代写代调试、POSIX Threads代编码的相关文章

R编程作业代写| 代写R编程分类作业|代写R作业|代做R语言作业

第一部分:关于表内的A.B方案的介绍:在研究第0-24周期间,课题方案为动态方案. 入组时若HBeAg>60 S/CO,给予A药物,即调肝益脾颗粒+恩替卡韦安慰剂(方案A),之后每4周进行一次检查,决定之后的治疗方案(见第二部分) 入组时若HBeAg<60 S/CO,给予B药物,即调肝健脾解毒颗粒+恩替卡韦(方案B),直至第24周结束. 第二部分:药物方案的动态转换 对于入组后应用A方案的患者,在前24周内,每4周进行一次含有ALT的肝功能检查和含有HBeAg的乙肝五项检查,根据指标进行药物转

代写java binary search trees|代写Java Data Structures CS作业|代写Java作业|Java 编程作业代写|Java作业代写

CS2230 Computer Science II: Data Structures Homework 7 Implementing Sets with binary search trees 30 points Goals for this assignment ? Learn about the implementation of Sets using binary search trees, both unbalanced and balanced ? Implement methods

Matlab代写、代写Matlab、Matlab编程代写代写Matlab编程test_TDPC_encoder

disp('===================================================================');disp('Test 1');radix = 2;rows = 0;columns = 4;message_vector = [0 1 1 0];try encoded_vector = TDPC_encoder(message_vector, radix, rows, columns); disp('FAILED: an error messa

代写MATLAB编程- MATLAB编程代写Design a pushdown automata (PDA)

Design a pushdown automata (PDA)1.Consider the language of all binary strings that start and end with the same symbol. (a) Write the production rules of a grammar for this language. Show some derivations to test that your grammar is correct. (b) Desi

代写asp编程程序、代写asp web网页制作

代写asp编程程序.代写asp web网页制作动态web程序设计课程设计 提交材料:网站全部文件.网站设计说明书起止时间:第14周--第16周 课程设计要求:1.根据动态web课程所学知识,个人独立开发一个动态网站,动态网站开发需要使用Dreamweaver CS5网页设计技术,ASP动态编程技术,数据库技术等,通过课程设计,将动态web课程的理论知识与实际应用结合起来,综合运用所学知识,提高学生分析问题和解决实际问题的能力,要求动态网站的内容不能完全雷同,如有雷同将被扣分. 2.完成2000字

Sqlite代写、SQL执行语句代写

Sqlite代写.SQL执行语句代写SQL Assignment 2 (20%)Questions:1. Produce a table showing the total books that are currently "CheckedOut" by every major. Show theMajor and "Total Books Checkedout" in the query result and sort the "Total Books

代写android编程作业、代写游戏作业

代写android编程作业.代写游戏作业功能要求分析该游戏要实现的功能描述如下: 关于:可以让玩家了解游戏的一些开发信息等. 帮助:可以让玩家了解游戏的相关玩法,学会如何玩这个游戏. 开始游戏:点击可以进入游戏界面,开始玩游戏. 设置:设置游戏中音乐和音效的开关状态.退出:退出游戏. 练习模式:玩家与系统之间的对战,利用android重力感应让乒乓球进行移动. 对战模式:玩家与玩家之间的对战,利用android重力感应让乒乓球进行移动. 另外,该游戏设计流程主要分三个阶段. 第一个阶段是游戏登录

代写二叉查找树程序作业、代写BST 作业、代写Data Structures

代写二叉查找树程序作业.代写BST 作业.代写Data StructuresKIT205 Data Structures and AlgorithmsAssignment 1: Data StructuresDue: 27th April, 11:55pmIntroductionYou work for an education company that develops and runs Massive Open Online Courses(MOOCs). You have been ask

代写statistical R 程序、代做留学生R统计作业

代写statistical R 程序.代做留学生R统计作业1. This is a take-home final exam.2. Answers to Questions 1,2,3,4 should be written using a Latex editor. Question 5 can beanswered using your preferred program. All answers should be merged in a single PDF andsubmitted i