Explain the per thread scoping, Operating System

Assignment Help:

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.

Related Discussions:- Explain the per thread scoping

What is segmentation?, SEGMENTATION In a memory management system that ...

SEGMENTATION In a memory management system that is properly a programmer views a program to be collection of program components called as segments . Every segment is a logical

Define implementation of segmentation with an example, IMPLEMENTATION OF SE...

IMPLEMENTATION OF SEGMENTATION WITH AN EXAMPLE Segmentation is a memory-management scheme that represents the user view of memory. A logical address space is the collection of

Find the parent process and the child process, Q. When a process creates a...

Q. When a process creates a fresh process using the fork() operation which of the following state is shared among the parent process and the child process? 1 Stack 2 Heap

Determine the syntax of the fork and join primitive, Determine the syntax o...

Determine the syntax of the Fork and Join Primitive  Answer: Syntax of the Fork and Join Primitive is as follow: Fork Join

How can the index blocks be implemented, How can the index blocks be implem...

How can the index blocks be implemented in the indexed allocation scheme? The index block can be implemented as follows a. Multilevel scheme b. Linked scheme c. Combin

What do you mean by semaphore?, What do you mean by semaphore?  Semap...

What do you mean by semaphore?  Semaphore : A synchronization variable that acquires on positive integer values. Invented by the Dijkstra P (semaphore): an atomic proce

Selection of a disk-scheduling algorithm, Q. How would utilize of a RAM di...

Q. How would utilize of a RAM disk affect your selection of a disk-scheduling algorithm? What factors would you require to consider? Do the similar considerations apply to hard-di

What is external fragmentation?, What is external fragmentation? As pro...

What is external fragmentation? As process are removed from and loaded to the memory free memory space is bracken into pieces .external fragmentation take place when enough mem

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd