Question

In: Computer Science

In a system with threads, is there normally one stack per thread or one stack per...

In a system with threads, is there normally one stack per thread or one stack per process? Explain.

Solutions

Expert Solution

Each thread has its own stack so it can utilize its own local variables, thread offer global variables which are essential for .data or .bss segments of linux executable.

Since threads share global variables that is, we use synchronization instruments like mutex when we need to get to/alter global variables in multi threaded application. Local variables are important for thread singular stack, so no need of any synchronization.

There is one stack for every thread whether you are utilizing real threads or simulated threads. A stack holds the call history of the thread and hence the factors of the calling schedules and the statement area from which they settled on the decision. At the point when you switch back to the thread, regardless of how it is executed, it can decide to "return" and should have a stack to actualize the return by reestablishing the past everyday practice at the point after the call. Obviously, on the off chance that you are simulating thread, at that point the substance of the "stack" might be not the same as the local stack oversaw by the OS and CPU, and deciphered dialects are allowed to make a stack dependent on pseudo-code instead of native machine guidelines. It is as yet a stack


Related Solutions

Thread Programming (C Programming) Objective Develop threads: thread and main. Functionality of Threads: The main program...
Thread Programming (C Programming) Objective Develop threads: thread and main. Functionality of Threads: The main program accepts inputs from the user from the console. The user can provide the following two types of input: add num1 num2 mult num1 num2 Here, num1 and num2 are two integer numbers. E.g., the user may input add 1 2. The threads receive the command along with the number, and performs the appropriate arithmetic operation and returns the results to main program. The main...
Name one advantage of associating user threads with kernel thread? Suggest an advantage and disadvantage of...
Name one advantage of associating user threads with kernel thread? Suggest an advantage and disadvantage of using mailboxes over shared memory for inter-process communication.
DO THIS IN JAVA Write a complete Java program. the program has two threads. One thread...
DO THIS IN JAVA Write a complete Java program. the program has two threads. One thread prints all capital letters 'A' to'Z'. The other thread prints all odd numbers from 1 to 21.
Threads: Assume a multithreaded application using user level threads mapped to a single kernel level thread...
Threads: Assume a multithreaded application using user level threads mapped to a single kernel level thread in one process (Many to one model). Describe the details of what happens when a thread (i.e. thread 1) executes a blocking system call (5 points). Describe what happens when thread 1 yields control to another user level thread, namely thread 2, in the same process. (NOTE: include the following in your description: what state is saved?, where is it saved? What state is...
Write a C program that creates 5 threads sends the thread index as an argument to...
Write a C program that creates 5 threads sends the thread index as an argument to the thread execution procedure/function. Also, the main process/thread joins the newly created threads sequentially one after the other. From the thread procedure print “I am a thread and my index is “ [print the correct index number]. From the main thread after the join print “I am the main thread and just completed joining thread index “ [print the correct index].
If bolt thread length is normally distributed, what is the probability that the thread length of...
If bolt thread length is normally distributed, what is the probability that the thread length of a randomly selected bolt is (a) Within 1.3 SDs of its mean value? (b) Farther than 1.5 SDs from its mean value? (c) Between 1 and 2 SDs from its mean value? You may need to use the appropriate table in the Appendix of Tables to answer this question.
If bolt thread length is normally distributed, what is the probability that the thread length of...
If bolt thread length is normally distributed, what is the probability that the thread length of a randomly selected bolt is (a) Within 1.3 SDs of its mean value? (b) Farther than 2.1 SDs from its mean value? (c) Between 1 and 2 SDs from its mean value?
You will create a number of threads—for example, 100—and each thread will request a pid, sleep...
You will create a number of threads—for example, 100—and each thread will request a pid, sleep for a random period of time, and then release the pid. (Sleeping for a random period of time approximates the typical pid usage in which a pid is assigned to a new process, the process executes and then terminates, and the pid is released on the process's termination.) On UNIX and Linux systems, sleeping is accomplished through the sleep() function, which is passed an...
Write a C code to let the main thread create N child threads, where each created...
Write a C code to let the main thread create N child threads, where each created thread will randomly generate an integer between 0 to 10 and put it into a global array variable. After that, the main thread will calculate the sum of all the generated integers. N should be input as a command line argument. Complete the following C code by filling all “???”s in the code sketch. NOTE: when you compile the code, you need to add...
Measurements of a number of fittings show that the pitch diameter of the thread is normally
Measurements of a number of fittings show that the pitch diameter of the thread is normally distributed with a mean of 8.007 mm and a standard deviation of 0.005 mm. The design specifications require that the pitch diameter be 8 ± 0.01 mm. Estimate the percentage of fittings that will be within tolerance.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT