Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function named sync_Func_Calls. This function receives a function pointer as its parameter. The sync_Func_Calls function runs every function that is passed to it

Write a function named sync_Func_Calls. This function receives a function pointer as its parameter. The sync_Func_Calls function runs every function that is passed to it atomically regardless of that the call has been made from a process or a thread and they are cooperating or not. The sync_Func_Calls will synchronize every function call. It means if different processes/threads call the same function simultaneously, its the responsibility of sync_Func_Calls to execute the call of each process/thread error-free (shared resource problem).

The prototype of the function is given below:

void* sync_Func_Calls(void*(*func_Name(void*)),void* arg)

Where arg is the argument to the function func_Name() passed as a void pointer in sync_Func_Calls.

The function sync_Func_Calls returns what the function (func_Name) returned value.

You can build a library of different functions (func_Name) as you wish.

Problem 2: Write an overloaded function of sync_Func_Calls that receives a semaphore variable sem too in addition to a function pointer and its argument. So that it can allow as many processes/threads to run simultaneously as specifies in semaphore value.

void* sync_Func_Calls(void*(*func_Name(void*)), void* arg, sem_t sem)

Note: Submit a single file containing both functions

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

Step: 3

blur-text-image

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 Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions

Question

why do consumers often fail to seek out higher yields on deposits ?

Answered: 1 week ago

Question

Have you been notified by the claims department of your rights?

Answered: 1 week ago