Determine the requiring variables on the scope of a thread, Operating System

Determine the Requiring Variables on the Scope of a Thread

It is very common in server application programs to require variables on the scope of a thread. To provide such a scope, the per-thread data item must be introduced. This data item may be used as a global variable, but each access needs to be made within the scope of a thread (that is, be unique for each thread). For instance, information such as errno must be unique to each thread or unpredictable results may occur. errno is a variable generally set by the operating system when certain application function are executed. Within NetWare , UnixWare, and OS/2, the variable is named errno. To receive the per-thread errno in Windows NT, the application must call GetLastError( ). Assume that two threads named A and B are making library function calls in which the errno variable will be set. If the two threads used the same global variable, the following might occur.

1. Thread A makes a call that results in an error and sets errno to 0X 10.

2. Thread B is then scheduled, makes a system call that executes properly, and sets errno to 0XX00.

3. Because Thread A and Thread B are using the same global errno, when Thread A queries errno it will have the results from Thread B.

This could be avoided if errno was of threads scope and thus was unique for each thread. All platforms with the exception of UnixWare consider errno with a thread scope, so each reference would only change the current thread's copy of errno UnixWare provides errno on the scope of the process, as threads are not supported. In addition, our thread-based platforms provide a mechanism for developers to access application-defined thread data areas.

Posted Date: 5/29/2013 5:39:04 AM | Location : United States

Related Discussions:- Determine the requiring variables on the scope of a thread, Assignment Help, Ask Question on Determine the requiring variables on the scope of a thread, Get Answer, Expert's Help, Determine the requiring variables on the scope of a thread Discussions

Write discussion on Determine the requiring variables on the scope of a thread
Your posts are moderated
Related Questions
How is memory management done using bit maps? A bit map is here in this we signify the bit value as 0 or 1. 1-hole 0-process In this we are able to represent the proce

why some companies do not pay sufficient attention to staff induction

What are the advantages of Contiguous allocation? The advantages are a. Supports direct access b. Supports sequential access c. Number of disk seeks is minimal.

Some CPUs provide for more than two modes of operation. What are two possible uses of these multiple modes?

For the heat conduction problem, investigate the effects on the numerical solution of the following aspects: 1. non-uniform meshes with re?nement at both ends versus a uniform m

what is it all about? why do we need? what are the types of backup? how is it done in unix?

explain the link between operations management and strategic planning of daily goods shop

Operating Systems 1. Explain single Partition Allocation and Multiple Partition Allocation. 2. What do you mean by PCB? What useful information is available in PCB? 3. De

Extend task 1 so that the requests are issued by the clients instead of the server. The server now do not use the "all_requests.dat" file. Instead every client thread reads from

Define properties of Time sharing operating system Time sharing:- T his systems uses CPU scheduling and multiprogramming to provide economical interactive use of a system. The