Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Kindly Solve Question no 3 by checking Question 1&2 . Put any space or anything else besides your SID in the file name. Q1) [20

Kindly Solve Question no 3 by checking Question 1&2 .image text in transcribedimage text in transcribed

Put any space or anything else besides your SID in the file name. Q1) [20 Marks] [CLO9-PLO5]You implemented Dinning philosopher problem with 5 philosophers and 5 chopsticks as one of your LabTasks. Now consider a simpler situation with only two philosophers and two chopsticks. Both philosophers think for random 100.unt of 100,000 micro seconds) to eat. You may find following lines helpful. static pthread_mutext mutex1 = PTHREAD MUTEX INITIALIZER; pthread_mutex_lock (&mutex1) usleep(int); Because they think more, so it is possible, as shown in sample run below, that one philosopher might go into a long thinking phase and the other philosopher might eat mor than once during this time. But at no time there will be a deadlock. nadeem@nadeem-VirtualBox: ~/FA21/code/FinalLab$ /TwoPhilos.exe Philosopher#1 wants to eat Philosopher#1 going to eat Philosopher#2 wants to eat Philosopher#1 done eating, now thinking.... Philosopher#2 going to eat Philosopher#2 done eating, now thinking.... hilosopher#1 wants to eat hilosopher#1 going to eat ilosopher#1 done eating, now thinking..... Philosopher#2 wants to eat Philosopher#2 going to eat Philosopher#2 done eating, now thinking... Philosopher#1 wants to eat Philosopher#1 going to eat Philosopher#1 done eating, now thinking.... Philosopher#2 wants to eat Philosopher#2 going to eat Philosopher#2 done eating, now thinking.... Philosopher#1 wants to eat Philosopher#1 going to eat Philosopher#1 done eating, now thinking.... Philosopher#1 wants to eat Philosopher#1 going to eat Philosopher#1 done eating, now thinking.... Philosopher#1 wants to eat Philosopher#1 going to eat Philosopher#1 done eating, now thinking.... Philosopher#2 wants to eat Q2) [20 Marks] [CLO9-PLO5] Write a simple calculator which can perform four basic math operations, i.e addition, subtraction, multiplication and division. You will create two .c files namely: main.c and functions.c main.c will contain the main function and call each of the four functions based on user input, functions.c will contain all four functions. Put all the functions of function.c in a static library called libmymathlib.a and link it with main.c : * Sample run of the program is as follows: $ ./mycalc.exe Please enter +, -, *,/or Q to quit : + Please enter two numbers that you want to add : 25 35 Result : 60 Please enter +, -, *,/or Q to quit: Q Thanks for using myclac Q3) [10 Marks] [CLO8-PLO5] Write a makefile which will build the al programs. The names of the executable files should be TwoPhilos.exe and my shown in the sample runs above. I am only going type make and expect your build the two programs as specified in the above two questions

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

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

Factors Affecting Conflict

Answered: 1 week ago

Question

Describe the factors that lead to productive conflict

Answered: 1 week ago

Question

Understanding Conflict Conflict Triggers

Answered: 1 week ago