Controlling Thread Attributes and Synchronization
- Threads and synchronization variables can have several attributes associated with them.
- Different threads may be scheduled differently (round-robin, prioritized, etc.),
- They may have different stack sizes, and so on.
- A synchronization variable such as a mutex-lock may be of different types.
- An attributes object is a data-structure that describes entity (thread, mutex, condition variable) properties.
- When creating a thread or a synchronization variable, we can specify the attributes object that determines the properties of the entity.
- Pthreads allows the user to change the priority of the thread.
- Subsequent changes to attributes objects do not change the properties of entities created using the attributes object prior to the change.
- $&bull#bullet;$
- There are several advantages of using attributes objects.
- 1
- It separates the issues of program semantics and implementation.
- Thread properties are specified by the user.
- How these are implemented at the system level is transparent to the user.
- This allows for greater portability across operating systems.
- 2
- Using attributes objects improves modularity and readability of the programs.
- 3
- It allows the user to modify the program easily.
- For instance, if the user wanted to change the scheduling from round robin to time-sliced for all threads,
- they would only need to change the specific attribute in the attributes object.
- $&bull#bullet;$
- To create an attributes object with the desired properties,
- $&bull#bullet;$
- we must first create an object with default properties and then modify the object as required.
Subsections
Cem Ozdogan
2010-12-27