Two threads in the same process share: file descriptors program counter global variables stack pointer heap
Added by Julia B.
Close
Step 1
This is because file descriptors are just integer values that refer to open files or other input/output resources, and they are managed by the operating system. So, multiple threads can use the same file descriptor to read from or write to the same file or socket, Show more…
Show all steps
Your feedback will help us improve your experience
Md.Daniyal Arshad and 96 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Select the correct alternative from the given choices. Assume that part of a program takes long time to execute. Select an option from below that can enhance performance: (i) Implement the part that takes long time as a separate process and use the results as needed from the main program. (ii) Implement both the parts as two different threads in the same process. (A) (i) only (B) (ii) only (C) Both (i) and (ii) (D) Neither (i) nor (ii)
OPERATING SYSTEM
PROCESSES AND THREADS
How is the read action different from the write action when multiple processes access the same file?
For the following program: 1. Sketch the corresponding process tree --- being sure to indicate outputs and circle synchronization points, if they exist. 2. List all distinct outputs that could be produced when it is executed. main() { int x = 0; printf("1"); if (fork() == 0) { printf("2"); x += 1; } else if (fork() == 0) { printf("3"); x += 1; } if (x < 1) { while (wait(NULL) > 0); printf("4"); } else { printf("5"); } }
Supreeta N.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Watch the video solution with this free unlock.
EMAIL
PASSWORD