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 a pure demand paging, What is a pure demand paging? When starti...

What is a pure demand paging? When starting implementation of a process with no pages in memory, the operating system sets the instruction pointer to the first instruction of t

Define thread cancellation and target thread, Define thread cancellation & ...

Define thread cancellation & target thread. The thread cancellation is the task of terminating a thread before it has completed. A thread that is to be cancelled is often refer

How does communication takes place in a distributed system?, How does commu...

How does communication takes place in a distributed system? Distributed systems depend on the networking for their functionality. A network is a communication path among two

Deadlock detection, Deadlocks can be detected while the program is running,...

Deadlocks can be detected while the program is running, by running cycle detection algorithms on the graph that de?nes the current use of resources. De?ne this graph as follows:

What are the different directory structures, What are the different directo...

What are the different directory structures? Explain each type. There are five dissimilar directory structures: 1.      Single level directory 2.      Two level directory

Write a note on threads, Question 1 Explain (a) tightly coupled systems   ...

Question 1 Explain (a) tightly coupled systems                               (b) Loosely coupled system Question 2 Describe the RPC model Question 3 Write a note o

Virtual memory, How a virtual memory can be implemented? What are the benef...

How a virtual memory can be implemented? What are the benefits of using virtual memory?

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