Question: Below is DBserver.c Use linux Copy DBServer.c above into a file in your filespace named labo5q1.c Modify labo5q1.c so that it has the same functionality

 Below is DBserver.c Use linux Copy DBServer.c above into a file

in your filespace named labo5q1.c Modify labo5q1.c so that it has the

Below is DBserver.c

same functionality as DBserver.c above, except that it uses the pthread library.

"Clean up" your new code to make it more clear and concise.

you can join threads much more simply. Actually, you HAVE to, given

this statement from "man pthread_join": There is no pthreads analog of waitpid(-1,

Use linux

Copy DBServer.c above into a file in your filespace named labo5q1.c Modify labo5q1.c so that it has the same functionality as DBserver.c above, except that it uses the pthread library. "Clean up" your new code to make it more clear and concise. you can join threads much more simply. Actually, you HAVE to, given this statement from "man pthread_join": There is no pthreads analog of waitpid(-1, &status, o), that is, "join with any termi nated thread". If you believe you need this functionality, you probably need rethink your application design. Try to verify that the same race condition can also occur in your labo5q1 program. (i.e., if you have time, run it until you see it print the "wrong" output.) Note to see how to get a thread's TID (Thread ID) in pthreads, see program /usr/courses/cps590/Programs/race_condition/add1.c Copy your file labo5q1.c to labo5q2.c, and then modify lab5q2.c to avoid the race condition by using an appropriate mutex. Verify your program will always correctly print 3036 when it is run 100 times in a row. You could do this with a simple loop, such as: for i in 1..100) do a.out 2>/devull | grep -v "36$" done #define GNU SOURCE //for Ubuntu #include #include #include #include #include #include #include #include int queryNo[3] {1011, 1012, 1013}; int total_queries = 0; int userThread (void *p) { int i; int a (int) (long)p; //set thread q on CPU 4 cpu_set_t set; CPU_ZEROC &set); CPU_SET( q, &set ); if (sched_setaffinity( getpid(), sizeof( cpu_set_t ), &set )) { perror( "sched_setaffinity" ); _exit(0); } for (i = 0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!