Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming in C, pthreading Processes 1. Write a C program to create two child processes using pthread_create(). Create a global int while the second child

Programming in C, pthreading

image text in transcribed

Processes 1. Write a C program to create two child processes using pthread_create(). Create a global int while the second child process does the same, but decrements the same variable. Have the parent of the children wait for the two children to complete and then print the value of the variable 2. Run your program several times. Do you always see 0 as the result? Explain 3. Trace system calls used by your program using strace nameofyourexecutable (-c option gives a summary of system calls only) 4. Identify the system call responsible for creation of your child process. 5. Modify your program so that your child processes protect the global variable using pthread_mutex lock() and pthread mutex unlockO) 6. Run your program several times. Do you always see 0 as the result? Explain 7. Trace system calls used by your program using strace nameofyourexecutable (-c option gives a summary of system calls only) 8. Identify the system call responsible for locking and unlocking the mutex. 9. Submit your final program using a mutex on D2L Don't forget when writing pthread programs! include To compile, add -Ipthread to the linker flags: gcc -lpthread-g

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications Dexa 2021 Workshops Biokdd Iwcfs Mlkgraphs Al Cares Protime Alsys 2021 Virtual Event September 27 30 2021 Proceedings

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Atif Mashkoor ,Johannes Sametinger ,Anna Fensel ,Jorge Martinez-Gil ,Lukas Fischer

1st Edition

3030871002, 978-3030871000

More Books

Students also viewed these Databases questions

Question

The nature and importance of the global marketplace.

Answered: 1 week ago