GATE IT 2005 | Question: 19, UGCNET-June2012-III: 57

6.2k views
A user level process in Unix traps the signal sent on a Ctrl-C input, and has a signal handling routine that saves appropriate files before terminating the process. When a Ctrl-C input is given to this process, what is the mode in which the signal handling routine executes?
1. User mode
2. Kernel mode
3. Superuser mode
4. Privileged mode

recategorized
2
Some one can explain this?? How's this work?
0
Why is it A and not B ?
0
@arjun sir plz explain this
0
@Bikram sir

in this why option b wrong ?

ctrl+c is hardware interrupt so it can be handle in kernel mode
9

A user level process in Unix traps the signal sent on a Ctrl-C input

That means when an user sent an input  an user level process handle that signal

That's why it is in user mode and not in kernel mode .

ctrl+c is hardware interrupt so it can be handle in kernel mode

Yes ctrl+c is hardware interrupt .. but it clearly mention in question that " an user level process in Unix traps the signal" , an user level process working in user mode so signal handling routine executes in user mode only.

You may see my detail answer below.

0

@Bikram Sir,

This trap might refer to the trap sent as the software interrupt to the os.

And it is mentioned that whatever trap occured(Whether in system or user process), results in switch to kernel mode.

Then, why answer A is valid in such Case?

Shouldn't the answer be (B) ?

0

Notice line --> Signals by default are handled by the kernel.

The default action for handling each signal is defined in the kernel too, and usually it terminates the process that received the signal.

So answer could be option (A) or (B). Please correct me if i am wrong.

https://stackoverflow.com/questions/6108953/how-does-ctrl-c-terminate-a-child-process

https://stackoverflow.com/questions/14960579/process-file-descriptors-and-sigkill-signal-behavior

https://stackoverflow.com/questions/2541597/how-to-gracefully-handle-the-sigkill-signal-in-java

0
signals may be handled by two possible handlers,default or if user defined overriding default one.Here which is handling the signal?default or user defined?
1
I think this question could be done by option elimination method:

Since b and d are the same hence they both cannot be the answer as multiple options not allowed.

Now, superuser mode is a mode that requires an administrator to do certain tasks.

Now think of a situation when you are using a computer in guest mode. Now you have written an infinite loop program and running in cmd. Now to stop cmd you will press ctrl+c and immediately the program stops without asking any permission. Now, this means CPU does not ask you for admin permission to do ctrl+c. This means the task can be done without going superuser mode.

Now, you have only one option left. Hence, A will be the answer.

2
is this in syllabus?

• When an user send an input to the process it can not be in privileged mode  as it is coming from an user so option D , Privileged mode can not be possible here ..

Now see , kernel mode = Privileged mode

• That means both option B and option D are equal. As option D can not be possible , option B also false.
• There is nothing called  superuser mode so option C is clearly wrong .
• Only option A is left , when an user input come like ' ctrl+c' the signal handling routine executes in user mode only as a user level process in UNIX traps the signal.

Hence option A is correct answer.

edited by
11
Slight correction: there is definitely something called Superuser mode in Linux, and it is somewhat close to "Run as administrator" in Windows. But since that too is closer to privelaged mode, your answer is correct.
1
Sir, I am not able to understand why answer would be d)user mode here. Please elaborate a bit more. Thank you.
0
Super user mode exists in System which is like administrator to all processes . It is similar to sudo , su commands what we use in OS .
2

I think it should be (b) Kernel Mode because Ctrl+C input causes a hardware interrupt and this causes appropriate interrupt handler routine to execute in kernel mode.

0
You're right.I think the answer should be (B) and not (A).
0
0

superuser mode ---

Sudo command

Sudo (superuser do) is a utility for UNIX- and Linux-based systems that provides an efficient way to give specific users permission to use specific system commands at the root (most powerful) level of the system

0

@BikramIn Linux we write sudo...something. Which means user mode, right?

0
according to this link it should be kernel mode right?
1
what is the difference between kernel mode and privledge mode... ?? why only A is answer not C?
1
Privilege mode and kernel mode both are the same thing so the  answer can be A or C
4

Kernel mode == Privileged mode

so option B == option D , when an user send a request it can not be in privileged mode so both option B and D are wrong ..

there is nothing called super user mode so option C is wrong clearly ..

we only left with option A , and that is correct option .

1 vote

Explanation.
Hardware interrupts (also called external/asynchronous interrupts), are ones in which the notification originates from a hardware device such as a keyboard, mouse , etc.
The most common way of sending signals to processes is using the keyboard:
• Ctrl-C: Causes the system to send an INT signal (SIGINT) to the running process.
• Ctrl-Z: causes the system to send a TSTP signal (SIGTSTP) to the running process.
The kernel handles signals in the context of the process that receives them, so
a process must run to handle signals.

1 vote
The question says "signal handling routine that saves appropriate files BEFORE TERMINATING THE PROCESS" . This means we are still in user mode. So answer is A.
1 vote

This is what the Galvin text has to say.  Usually, there are two types of signal handlers: Kernel Level and user level. Now the kernel level is the default one. But if we look at the wordings of the question in details :

A user level process in Unix traps the signal sent on a Ctrl-C input, and has a signal handling routine that saves appropriate files before terminating the process.

It clearly means that the signal handling routine is a part of the user-level process and hence it shall run in user mode.

Ans: (A) USER MODE

Related questions

1
8.9k views
A common property of logic programming languages and functional languages is: both are procedural languages both are based on $\lambda$-calculus both are declarative both use Horn-clauses
A computer system supports $32$-bit virtual addresses as well as $32$-bit physical addresses. Since the virtual address space is of the same size as the physical address space, the operating system designers decide to get rid of the virtual memory entirely. ... can be made more efficient now Hardware support for memory management is no longer needed CPU scheduling can be made more efficient now
What is the output printed by the following program? #include <stdio.h> int f(int n, int k) { if (n == 0) return 0; else if (n % 2) return f(n/2, 2*k) + k; else return f(n/2, 2*k) - k; } int main () { printf("%d", f(20, 1)); return 0; } $5$ $8$ $9$ $20$