305 views
0 votes
0 votes
We know each process has its process table which have process ID, PC, priority, list of open files etc etc... Now if we have two process A and B.. OS issues process A to the processor.. process A starts its execution and it open a file.. After this process context switch and process B get a chance.. Process B closes the file which process A has opened..

Now what will happen..?

Will there be a change in entries in process table of process A.. what will happen when process A will resume its execution..

1 Answer

0 votes
0 votes
This problem somewhat resemble with reader- writer problem of critical section ..

In your case both process are trying to access the same file , first process A after opening it preempted so the file and its bookmarks all are save in context of that process now second process is also trying to open it .

So for that we have two cases here..

First , if that file has read and write facility then access to that file will be mutually exclusive ( means at one time only one process can access it ) ...

Second , if that file has only read facility then any no. Of process can access it simultaneously ...( i.e.In your case both process trying to access same file)..

Now if process B closes the file then it is for his context ... not for process A ..

Process A still have it bookmarks to that file save in its context...
edited by

Related questions

0 votes
0 votes
1 answer
1
Nam14 asked Apr 5, 2023
514 views
Please read below passage from 10th edition Operating System Concepts, pg. 202:5.1.3 Preemptive and Nonpreemptive SchedulingCPU-scheduling decisions may take place under ...
0 votes
0 votes
0 answers
2
Iamniks4 asked Jan 16, 2019
227 views
Caption
0 votes
0 votes
0 answers
4
Iamniks4 asked Jan 12, 2019
129 views
The following is the code with two threads, producer and consumer, that can run in parallel. Further, S and Q are binary semaphores equipped with the standard P and V ope...