Question: Untar the contents to a folder, and type make. This will produce the following: 1 ) SListSimpleTest program, which is a single threaded test program

Untar the contents to a folder, and type make. This will produce the following:
1) SListSimpleTest program, which is a single threaded test program to test the NodeSLList class. And it works just fine.
2) SListSimpleTest_Threaded program, which will NOT work until you properly add thread synchronization in NodeSLList_Threadable.h and NodeSLList_Threadable.cpp.
Your task is to add the proper synchronization to the linked list so it works with both SListSimpleTest AND SListSimpleTest_Threaded.
I would take the following approach:
1) Add syncrhonization, and test it with SListSimpleTest first. Once you have gotten past all the deadlock issues you will most likely created, and it works, move one.
2) Test your syncronization with SListSimpleTest_Threaded. While the list will become stranglely populated because 2 threads are adding and removing nodes, you should not get any deadlock issues, segmentation issues, or cases where the contents of the linked list were not expected (e.g. garbage values)
Hint: You should never need to protect constructors and destructors in C/C++, because only 1 thread can create an object at one time. It's only when multiple threads start using the one instance do you run into problems. That is why SListSimpleTest_Threaded has seperate functions to test construction and destruction.

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 Programming Questions!