Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Operating System Expert

The term thread-safe in computer programming describes that routine or portion of the program that may be called from multiple programming threads without uncalled for interactions between the threads. (The instance of the program which runs on behalf of some user or process is called Thread) The importance of thread safety to object oriented programming language is that it gives built-in support for threads. By the use of thread-safe routines, the risk of one thread interfering and modifing data elements of another thread gets eliminated by circumventing future/potential data race situations with coordinated access to shared data. 

It is possible to ensure that a routine is thread-safe by ensuring that synchronized algorithms are used by the concurrent threads use that cooperate with each other and limiting the shared object's  address to a single thread each time an unsynchronized algorithm is active. 

Web Reference: by Douglas C. Schmidt, 2005

                        Strategized Locking, Thread-safe Interface, and Scoped Locking                       

 

                    Present your own fully documented and tested programming example illustrating the use of locks to govern access to critical sections.

 

std::atomic inspct = 0;

int counts = 0;

Lock lck; ----

 

    if (lck.TryEnter()) {

        inspct.store(/* get thread id */, memory_order_relaxed);

        return true;

    }

    return false;

} 

bool TryEnter() {

    if (inspct.load(memory_order_relaxed) == /* get thread id */) {

        counts += 1;

        return true;

    } 

void Exit() {

    if (counts != 0) {

        counts -= 1;

        return;

    }

    inspct.store(0, memory_order_relaxed);

    lck.Exit();

}

The atomic variables do not cause data races, even in the most relaxed states. Here the variable is declared as atomic, There is no reason why the compiler would assume that the write can’t be implimented by other threads. 

Operating System, Computer Science

  • Category:- Operating System
  • Reference No.:- M9503678

Have any Question?


Related Questions in Operating System

Catalog course descriptionin this course students carry out

Catalog Course Description In this course students carry out independent research in a significant technical area of information, network, and computer security. The student is to investigate a technical area, research i ...

Discussion question this research assignment will give

Discussion Question : This research assignment will give further information on the nature and workings of multi-tasking and multi-processing operating systems. All information reported in this assignment is to be in the ...

State the required answer precisely and then provide proper

State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. Briefly describe the following concepts and indicate how they are related in the context ...

Question what do you see as the major differences between

Question : What do you see as the major differences between UNIX/Linux and other operating systems, such as Windows and Mac OS X? The response must be typed, single spaced, must be in times new roman font (size 12) and m ...

Foundation of information technologyresearch types of

Foundation of Information Technology Research types of operating systems that are currently available and provide a scenario in which the operating system you chose would be appropriate to be used in this situation. Expl ...

Question 1answer the following questions 10 marks a

Question 1 Answer the following questions: 10 marks a. Consider the following page reference string: 3, 1, 4, 1, 2, 3, 5, 3, 2, 1, 2,5, 4, 3, 5, 2, 4,2, 5,3 Using the above page reference string display the contents of t ...

Question you are a security administrator responsible for

Question: You are a security administrator responsible for providing secure configuration requirements for new laptop deployments. After reading Module 2 of Certified Secure Computer User v2exercises, apply the configura ...

State the required answer precisely and then provide proper

State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. Consider a computer embedded in the control of a manned spacecraft. Would it require an ...

Question note apa format 250 words and three reference

Question: Note: APA format 250 words and three reference without plagarism Computerized Operating Systems (OS) are almost everywhere. We encounter them when we use out laptop or desktop computer. We use them when we use ...

Assignment -building a multi-threaded web server using c

Assignment - Building a multi-threaded web server using C and p threads, following the model from the lecture. Your program will have one thread acting as a dispatcher thread, listening fornetwork connections with reques ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As