Next: Attributes Objects for Threads
Up: Programming Shared Memory
Previous: Condition Variables for Synchronization
Contents
Controlling Thread and Synchronization Attributes
- Threads and synchronization variables can have several attributes associated with them. For example, different threads may be scheduled differently (round-robin, prioritized, etc.), they may have different stack sizes, and so on. Similarly, 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. Once created, the thread or synchronization variable's properties are largely fixed (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.
- There are several advantages of using attributes objects.
- First, 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.
- Second, using attributes objects improves modularity and readability of the programs.
- Third, 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.
- To create an attributes object with the desired properties, we must first create an object with default properties and then modify the object as required.
Subsections
Next: Attributes Objects for Threads
Up: Programming Shared Memory
Previous: Condition Variables for Synchronization
Contents
Cem Ozdogan
2006-12-27