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 banker''s algorithm, What is banker's algorithm? Banker's algor...

What is banker's algorithm? Banker's algorithm is a deadlock avoidance algorithm that is applicable to a resource-allocation system with multiple examples of each resource type

Define process swapping , Swapping : Whole process is moved from the swap...

Swapping : Whole process is moved from the swap machine to the main memory for execution. Process size must be equal or less than to the used main memory. It is easier to exe

Explain drawbacks of fixed partitioning, The drawbacks of fixed partitionin...

The drawbacks of fixed partitioning are: The number of partitions are précised at system generation time limits the number of active processes in the system. For the re

What is an i/o subsystem, What is an I/O subsystem? The control of devi...

What is an I/O subsystem? The control of devices connected to the computer is a main issue while designing operating systems. Because I/O deices differ widely in their function

Explain independent process and a cooperating process, Question: a) Ea...

Question: a) Each process is represented in the operating system by a process control block (PCB). The PCB contains many pieces of information associated with a specific proce

Explain the circumstances under which os use mutexes, Q. Give the reasons ...

Q. Give the reasons why Windows XP, Solaris and Linux implement multiple locking mechanisms. Explain the circumstances under which they use mutexes, spinlocks, semaphores, adaptiv

Write knowledge base relevant propositional statement, Suppose a logic-base...

Suppose a logic-based agent in the wumpus world has found that locations (1,1) and (2,1) do not contain a stench, but that locations (3,1) and (2,2) do contain a stench. Can the ag

Explain the entry-sequenced file organization, Entry-sequenced file organiz...

Entry-sequenced file organization The records in an entry-sequenced file are store up in the order they are written into the file. New records are for all time appended to

Deadlock-avoidance safety algorithm, Q. Presume that you have coded the de...

Q. Presume that you have coded the deadlock-avoidance safety algorithm as well as now have been asked to implement the deadlock-detection algorithm. Can you do thus by simply usin

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