C-line Chengdai-generation debugging, POSIX Threads Generation Code

Source: Internet
Author: User
Tags posix sorts

C-line Chengdai-generation debugging, POSIX Threads Generation Code
(CSCI 363) Project--POSIX Threads
Instructions
This program sorts strings using "enzymes". An enzyme was a function that sorts the 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 are come in.
Before you edit the code, read through it, and answer these questions:
1) Briefly explain why this application would is difficult to write using multiple processes
instead of threads.
2) What is the significance of ' workperformed '? How is it used?
3) Explain exactly what's 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 the This function. It's simple fix, but could take a while for your to find it.
3) The function ' Join_on_enzymes ' is incomplete. Read the relevant mans pages and figure out
How the function was supposed to work. Then insert the correct code snippets into
' Whatgoeshere '.
4) Your programming work can is considered complete if you have completed the above
And all of the tests pass.
Testing
Make Test
./enzyme-test-f0 All
Running tests ...
1.make::p
2.sort::p
3.pleasequit1::p
4.pleasequit0::p
5.SWAP1::p
6.SWAP2::p
7.SWAP3::p
8.run_enzyme::p
9.join::p
10.cancel::p
Also want to experiment with the Cancel function-
./enzyme Cba
./enzyme CBA
Questions
1) Why does 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? Would the swap
Counts always being identical?
3) Threads is cancelled if the string contains a ' C ' e.g. "cherub". Why does we not include
Cancelled threads when adding up the total number of swaps?
4) What happens if a thread tries to join itself? (need to create a test
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 are used in the this MP.
7) briefly explain the bug in #2 of the "Fix the program" section above.
Turn in
ENZYME.C (i.e. finish fix the program sections tasks) and yourname.docx (i.e. answer the
Questions above). Due date'll is announced on Blackboard.
Http://www.daixie0.com/contents/13/1306.html

Our Direction field: Window Programming numerical algorithm AI Artificial Intelligence financial statistical Metrology analysis Big Data network programming Web programming Communication Programming game Programming Multimedia Linux plug-in programming API image processing embedded/Microcontroller database programming console process and thread Network security assembly language Hardware programming software Design Engineering Standard Rules. The generation of programming languages or tools including, but not limited to, the following ranges:

C/c++/c# Write

Java Write generation

It generation

Python writes

Tutoring Programming Jobs

The MATLAB Generation writes

Haskell writes

Processing Write

Linux Environment Setup

Rust Generation Write

Data Structure assginment Data structure generation

MIPS Generation Writing

Machine Learning Job Writing

Oracle/sql/postgresql/pig database Generation/Generation/Coaching

Web development, Web development, Web site jobs

Asp. NET Web site development

Finance insurace Statistics Statistics, regression, iteration

Prolog write

Computer Computational Method Generation

Because of professional, so trustworthy. If necessary, please add qq:99515681 or e-mail:[email protected]

: Codinghelp

C-line Chengdai-generation debugging, POSIX Threads Generation Code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.