3.5k views

Which of the following actions is/are typically not performed by the operating system when switching context from process $A$ to process $B$?

1. Saving current register values and restoring saved register values for process $B$.
3. Swapping out the memory image of process $A$ to the disk.
4. Invalidating the translation look-aside buffer.
edited | 3.5k views
0
@Bikram Sir @Debashish

Context switching can occur only in kernel mode it means it is done only by operating system then how swapping process is not performed by os ?

I got answer that memory manager swaps process https://en.wikibooks.org/wiki/Operating_System_Design/Swapping .pls explain
+7

swapping-out of the memory-image of a process to disk is not done on every context switch by OS as it would cause a huge over head

+1
Bikram sir According to korth,,
whenever the cpu scheduler decides to execute a process it calls the dispatcher .the dispatcher checks to see whether the next process in the queue is in memory.if not,the dispatcher swaps out a process currently in memory and swapped in the desired process .it then reloads registers as normal and transfer control to the selected process .The context switch time in such a swaping system is fairly high.
0

Bikram sir,pls also explain this line ,m confused between user and memory manager

"if a new process is loaded and there is insufficient main memory an od process is swapped to disk.This os ,however does not provide full swaping,because the user,rather than the scheduler ,decides when it is time to preempt one process for another.Any swapped out process remains swapped out until the user selects that process to run"

As wiki says

swapping can be implemented in various ways. For example, swapping can be priority based. That means if a higher priority process arrives and wants service, the memory manager can swap out the lower priority process to the secondary memory so that it higher priority process can be loaded to main memory for execution. As soon higher priority process finishes, the lower priority process will be swapped back to main memory and execution will be continued

0
what is the meaning of "memory image of process A"[email protected] ...plz help!
0
Context switching and swapping us two different thing ? Please explain their clear differences.

The above answer covers most of the things. Trying to add some more points to make it clear for people like me for those it is quite difficult to understand.

Processes are generally swapped out from memory to Disk (secondary memory) when they are suspended. So. Processes are not swapped during context switching.

TLB : Whenever any page table entry is referred for the first time it is temporarily saved in TLB. Every element of this memory has a tag. And whenever anything is searched it is compared against TLB and we can get that entry/data with less memory access.

And Invalidation of TLB means resetting TLB which is necessary because A TLB entry may belong to any page table of any process thus resetting ensures that the entry corresponds to the process that we are searching for.

Hence, option (C) is correct.

edited
+2
But TLB's have ASID(ADDRESS SPACE IDENTIFIER) ....which help it to distinguish between processes & their memory space ie Address Space Protection .

then why is Invalidating TLB necessary with each context Switch >
+5
When a task exits, the ASID is invalidated from the caches and TLBs and is reallocated to another task.
0
+1
why we are changing address Translation table?
+8

A program is comprised of segments (data, code, stack, etc.)

A logical address is a pair consisting of a segment number and a byte offset (displacement) within the segment.

The hardware architecture defines a segment table containing one entry per segment.  It is normally implemented as an array indexed by segment number.

Each segment table entry contains the base address and limit / length of the segment. This segment table is  known as address translation table.
0
Isn't that address translation table also called page table which contains entries of pages(the segment is divided into these pages) specific to that segment?
0
is is really that Address Translation Table and Page Table are two different entities. Here you are saying that segment table's other name is Address Translation Table
+3

Processes are generally swapped out from memory to Disk (secondary memory) when they are suspended. So. Processes are not swapped during context switching.

I can't totally agree with this..

Consider a case of Round Robin scheduling where time quantum expires and context switch takes place from A to B. No what if B was not already present in the MM and also there is no free region in MM? Then in order to execute, B has to be brought to MM by swapping out a process.

This is from Galvin 7th edition :

I understand that it is not always necessary to swap out a process..it is required only when there is no free space. But swapping does occur during context switching too (and not just for suspended process).

Also, I can't understand how TLB using ASIDs won't work here. If swapping out takes time then the flushing of contents in TLB and replacing it with new process's entries will also take time. For TLBs not supporting ASIDs D) is right.

So why not C and D both correct because both of them depend on certain situations and can't be generalized?

0
@bikram sir please clear @minipanda comment as it seems to be correct
option C) because swapping out of the memory image of a process to disk is not done on every context switch as it would cause a huge over head but can solve problems like trashing.
+2
is it necessary that "invalidating TLB" during context switch ???
+27
Yes. Invalidation is necessary. Otherwise the new process might end up using the translation of the old process. Saving and reuse of TLB is not necessary but can lead to better performance.
+4
But TLB's have ASID(ADDRESS SPACE IDENTIFIER) ....which help it to distinguish between processes & their memory space ie Address Space Protection .

then why is Invalidating TLB necessary with each context Switch >
+1
+1
If OS isn't involve in Swapping out the memory image of process A to the disk then which part of the system is involved?
+7
yes, OS is involved in " Swapping out the memory image of process A to the disk "

but in case of context switch swapping to disk is not done ..due to huge overhead.
+7

means changing the size of segments or length of that segment in table .

This address translation table contains the base address and length of the segment.  so changing length of the segment  is performed by the operating system when switching context from process A to process B.

0
there can be two approaches in case of TLB we can invalidate it or we need not in case we need not we can increase efficiency as the TLB in case of multi programming environment contains the frame base addresses of the pages used by the processes recently(more than one ) so if we invalidate it and in case we swap the present process immedeatly then this may lead us to access that from the page table instead of being a TLB HIT and what i think about address translation tables is changing the PAGE TABLE BASE REGISTERS ADDRESS MAINTAINED BY THE PROCESSOR AND THIS SHOULD BE SURELY DONE ...SO the answer is obviously C
0

@Arjun sir , if i am not wrong .isn't the explanation for TLB contradicting this answer

https://gateoverflow.in/644/gate2000-1-20-isro2008-47

0
0

says -:$\text{TLB are NOT necessarily saved during Context switch , }$

$\text{they are done just to ensure better perfromance}$

based on this, answer to this question should be both $C,D$

I am not sure i am right .

+13
Saving and invalidating are not the same. "Invalidation" is necessary -- because otherwise the process can get corrupted. If not saved, while resumption there will just be a lot more TLB misses -- slow execution but still correct.
+1
Thats it .I missed to specify that i got confused between Invalidation and saving .Thank you sir :)

1