Consider the program given below, where a process creates a thread by calling a function named as "runner" that was defined before. The "runner" function changes the value of "I"; int i = 5; int main() { pthread_t pid; pthread create(pid,NULL,runner, NULL); printf("%d",i); //line #1 Which of the following is correct? Relect one

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter11: Operating Systems
Section: Chapter Questions
Problem 14VE
icon
Related questions
Question
Consider the program given below, where a process creates a thread by calling a function named as "runner" that was defined before. The "runner" function changes
the value of "i";
int i = 5;
int main ()
{
pthread t pid;
pthread_create (pid,NULL,runner, NULL);
printf("%d",i); //line #1
}
Which of the following is correct?
Select one:
Line #1 will be executed after the thread terminates
The updated value of "i' will be displayed
The thread can not run in parallel with the main process.
The thread will be called after the main function is completed
The main process may display 5.
Transcribed Image Text:Consider the program given below, where a process creates a thread by calling a function named as "runner" that was defined before. The "runner" function changes the value of "i"; int i = 5; int main () { pthread t pid; pthread_create (pid,NULL,runner, NULL); printf("%d",i); //line #1 } Which of the following is correct? Select one: Line #1 will be executed after the thread terminates The updated value of "i' will be displayed The thread can not run in parallel with the main process. The thread will be called after the main function is completed The main process may display 5.
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Avoiding deadlock
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning