The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+27 votes
2.6k 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.
  2. Changing address translation tables.
  3. Swapping out the memory image of process A to the disk.
  4. Invalidating the translation look-aside buffer.
asked in Operating System by Veteran (59.4k points)
edited by | 2.6k 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
+4

set2018

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

0
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

2 Answers

+43 votes
Best answer

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.

answered by Boss (27.8k points)
selected by
+1
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
When a task exits, the ASID is invalidated from the caches and TLBs and is reallocated to another task.
0
how about changing address translation tables comes into the play?
+1
why we are changing address Translation table?
+5
In case of Logical address to Physical address translation Address translation Table is used.

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?
+32 votes
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.
answered by Active (1.5k points)
+2
is it necessary that "invalidating TLB" during context switch ???
+21
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.
+3
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
how about changing address translation tables?
0
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?
+3
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

@ankyAS 

Changing address translation tables

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
What is the contradiction?
0

sir answer to this https://gateoverflow.in/644/gate2000-1-20-isro2008-47 

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 .

+6
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 :)


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

35,488 questions
42,747 answers
121,459 comments
42,138 users