Doubt in Stage 27

57 views
Skip to first unread message

ALEN ANTONY

unread,
Nov 12, 2022, 5:41:37 AM11/12/22
to XOS Users
Imagine a situation like this, a process has to read from a file, so it invokes read system call with logical address for the variable, in the system call it is converted to the physical address, and it is passed on to buffered read function. In the buffered read function, it might have to load the file from the disk, so it goes to the wait state invoking scheduler. Now if this process gets swapped out and its later swapped back in, the stack pages allotted would become different and the physical address generated earlier would become invalid.Is there a way to handle this.

Murali Krishnan

unread,
Nov 12, 2022, 6:57:14 AM11/12/22
to xos-...@googlegroups.com
The current design won't swap out the stack page of a process.   So, the stack page won't change. 
However, the scenario can come with the heap page.   If I don't miss something, this is probably a design flaw.
 
It can be fixed if the PID of the process issuing read is passed as an additional argument to buffered read. 
(Now,  by dividing by 512 and checking the page table of the process, one can validate the physical address.
 If the physical address is on the stack page, the address will be valid.
 Otherwise, if it is a heap page, the page table can be checked for the correct page number. 
 Before writing data. Buffered_Read may have to first swap back the page (if swapped out)).

 I think Buffered Read should have been designed with PID and logical address as arguments rather than physical address. 

 Did I miss a point somewhere?  Any of the seniors?  It is a nice catch anyway! 
 Murali





On Sat, Nov 12, 2022 at 4:11 PM ALEN ANTONY <alen_b2...@nitc.ac.in> wrote:
Imagine a situation like this, a process has to read from a file, so it invokes read system call with logical address for the variable, in the system call it is converted to the physical address, and it is passed on to buffered read function. In the buffered read function, it might have to load the file from the disk, so it goes to the wait state invoking scheduler. Now if this process gets swapped out and its later swapped back in, the stack pages allotted would become different and the physical address generated earlier would become invalid.Is there a way to handle this.

--
You received this message because you are subscribed to the Google Groups "XOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xos-users+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/xos-users/66a484f6-555e-4843-950e-160f8a67716en%40googlegroups.com.

ALEN ANTONY

unread,
Nov 12, 2022, 7:45:29 AM11/12/22
to XOS Users
Thank you for the reply sir. Actually the current design given in eXpos documentation, swaps out the user stack pages as well. The User Area Page of the process is not swapped out.I could correct the issue by using the logical address passed to the buffered read function.  Also if a system call gets blocked  (eg. for. Disk Read), if we have already calculated the physical address for the return value in the stack before invoking the disk read , the process goes to WAIT_DISK state and the scheduler is invoked. If the process in WAIT_DISK state gets swapped out and after sometime swapped back in, the physical address calculated for return value gets invalid. So the physical address for the return value in stack will have to be calculated after every  blocking module call.

Murali Krishnan

unread,
Nov 13, 2022, 1:03:23 AM11/13/22
to xos-...@googlegroups.com
You are right, the user stack is swapped.   As you suggested, passing the logical address and calculating the physical address only just before the transfer suffices. 

Reply all
Reply to author
Forward
0 new messages