LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 11-07-2015, 06:34 PM   #1
particlereddy
LQ Newbie
 
Registered: Nov 2015
Posts: 7

Rep: Reputation: Disabled
sys_kill vs ctr+c


Hi All,
i am newbie to Linux. I am slowly gaining knowledge in kernels. i have a doubt in system calls vs kill signals.

i see there is a System Call Interface named sys_kill. I understand any system calls are delivered to kernel as part of TRAP. This is a HARDWARE INTERRUPT WITHIN CPU.

i also understand CTRL+C, which generates SIGINT is a software interrupt rather hardware interrupt.

can someone tell me how does ctrl+c flows through the kernel, does it do any system call, or its just a pure software interrupt.

Also, plz correct my understanding.

Thanks
vlsireddy
 
Old 11-07-2015, 06:48 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
sys_kill is the kernel-internal function called when the kill(2) system call is made. AFAIK anyway. Try man 2 kill.

All signals are delivered to processes by the kernel. The origin of those signals can be a hardware trap like access to nonexistent memory or division by zero, or another process making the kill system call (SIGINT is in that category), or the kernel itself as a consequence of some action by the process (e.g. SIGSTOP when a background process tries to read from stdin).

When you type ctl-c, the shell will use the kill(2) system call to have the kernel send SIGINT to the foreground process. So, ctl-c does generate a system call, and it is purely software (after all, the kernel is purely software).

Last edited by berndbausch; 11-07-2015 at 06:49 PM.
 
1 members found this post helpful.
Old 11-09-2015, 07:14 PM   #3
particlereddy
LQ Newbie
 
Registered: Nov 2015
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thanks for your answer.
 
Old 11-10-2015, 01:48 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
Also: be careful understanding terms like "software interrupt," which could have a meaning (in context) different from what you assume or expect.

The strictest meaning of that term, is that it is a (CPU ...) interrupt that originates from software, instead of external hardware, but that is treated by the CPU in much the same way. Exactly what does and doesn't fall into this category is a gray area, but the 80x86 INT instruction is a very-obvious example. This instruction was used to implement system-calls in the days of MS-DOS, because it literally caused an interrupt, and therefore a transition from user to supervisor state. The TRAP instruction is much the same. "Like all 'interrupts,' it is handled directly by the CPU," but the source of the interrupt comes from software, not a physical wire.

When you talk about things like SIGINT, these really are an entirely(!) different thing, because the microprocessor knows nothing about such things. So, let's call them signals. A signal is delivered to a process/thread, and its actual effect is to alter the way that the Linux dispatcher deals with it, starting the next time that the dispatcher chooses to allow it to run. When the target process is next dispatched, it will be sent into a "signal handler" in its own user-space code, the kernel having also arranged things such that, when the signal-handler returns, the process will resume where it left off. (Unless the nature of the signal is that "the process dies," in which case the executed code causes the process to graciously achieve its own death.)

Although this procedure is analogous to the CPU's handling of "an interrupt," it is not the same, and the CPU has no direct awareness of it.

Last edited by sundialsvcs; 11-10-2015 at 01:50 PM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] cryptsetup: how does ctr-essiv work exactly ? (versus ctr-plain) metaschima Linux - Software 1 02-08-2015 07:11 PM
ctr-alt-delete windows = ??? ubuntu jgag123 Linux - Newbie 27 01-11-2008 01:54 PM
i8042.c: Can't write CTR while loading AUX. nasheia Linux - General 0 08-23-2006 08:44 AM
CTR-ALT-F1 kills X server arc2v Linux - General 3 05-24-2006 07:04 AM
linux equivilant to ctr+alt+del aggierian Linux - Newbie 5 06-09-2004 07:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 12:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration