explain the per thread scopingthread-level


Explain the Per Thread Scoping

Thread-level programming introduces new twists for application-level variable scoping. Threads are commonly used in one of two ways.

  • To execute independent parts of the application program
  • To execute similar application functions on a per-user basis

 

In the latter case, any global variables used by the threads may be subject to modification by more than one thread at a time. Disastrous results may occur if this is left unchecked.

Since threads are potentially executing  the same procedures within an application. Or accessing similar data, per-thread data items may be required.

A common practice in a multithreaded program is  to repentantly call application functions on a per-user or per-function basis. In order to make a function reentrant, variables within the function must either be local or have sterilized access to global data. When executing functions on be half of a user, however, these functions may need access to some user contextual data.

The application developer has one of two choices to make:

  • A variable could be passed to the functions representing an index into a user data structure or a pointer to user data. This is cumbersome, however, because that same variable will need to be passed to each subsequent function so that its scope is visible to application components down the line.
  • The developer can set up a similar variable with the global application scope but with per-threads access. The user data must be unique for each thread and be globally addressable by application functions.

Request for Solution File

Ask an Expert for Answer!!
Operating System: explain the per thread scopingthread-level
Reference No:- TGS0289665

Expected delivery within 24 Hours