public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Ukil a <ukil_a@yahoo.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Need help in understanding  x86  syscall
Date: Thu, 11 Aug 2005 09:54:36 -0400	[thread overview]
Message-ID: <1123768476.17269.46.camel@localhost.localdomain> (raw)
In-Reply-To: <20050811053931.71120.qmail@web51604.mail.yahoo.com>

On Wed, 2005-08-10 at 22:39 -0700, Ukil a wrote:
> I had this question. As per my understanding, in the
> Linux system call implementation on x86 architecture
> the call flows like this int 0x80 -> syscall ->
> sys_call_vector(taken from the table)-> return from
> interrupt service routine. 
> 
> Now I had the doubt that if the the syscall
> implementation is very large will the scheduling and
> other interrupts be blocked for the whole time till
> the process returns from the ISR (because in an ISR by
> default the interrupts are disabled unless “sti” is
> called explicitly)? That’s appears to be too long for
> the scheduling or other interrupts to be blocked? 
> Am I missing something here?

This is where interrupt is not a good term for syscall. It is really a
trap.  An interrupt is an outside source that stops the CPU from doing
what it was doing to go do something else (asynchronous event).  A trap
is something that the CPU calls on itself to do something else
(synchronous event).  So when a network packet comes in, the NIC sends
an interrupt request (request since the CPU may not immediately handle
it), and when the CPU is ready (interrupts on) it will stop what it is
doing and handle the network packet.

When you do a system call, it is a trap.  Quoting the Intel manual:

  The difference between an interrupt gate and a trap gate is as follows. If an interrupt or exception
  handler is called through an interrupt gate, the processor clears the interrupt enable (IF) flag in
  the EFLAGS register to prevent subsequent interrupts from interfering with the execution of the
  handler. When a handler is called through a trap gate, the state of the IF flag is not changed.


So when you go into the kernel through a trap (system call) interrupts
are still on if they were on to begin with, which is the case when
coming from user mode. But when you come into the kernel through a real
interrupt, then interrupts are off.

Also note that if you have preemption disabled, the system call will
_not_ do any scheduling unless it explicitly calls schedule.  If you
turn on voluntary preempt, it will call schedule at various spots in the
kernel that might call schedule anyway.  If you turn on full preemption,
then the process can be scheduled out anywhere in the kernel unless it
explicitly says it doesn't want to (preempt_disable or spin_lock).

-- Steve


  reply	other threads:[~2005-08-11 13:54 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-11  5:39 Need help in understanding x86 syscall Ukil a
2005-08-11 13:54 ` Steven Rostedt [this message]
2005-08-11 15:52 ` Zachary Amsden
     [not found] <4Ae73-6Mm-5@gated-at.bofh.it>
2005-08-11 13:41 ` Bodo Eggert
2005-08-11 14:04   ` linux-os (Dick Johnson)
2005-08-11 14:31     ` Steven Rostedt
2005-08-11 15:13       ` Coywolf Qi Hunt
2005-08-11 15:22         ` Steven Rostedt
2005-08-11 15:28         ` linux-os (Dick Johnson)
2005-08-11 15:51           ` Steven Rostedt
2005-08-11 16:19             ` Steven Rostedt
2005-08-11 16:31               ` Coywolf Qi Hunt
2005-08-11 16:59                 ` Coywolf Qi Hunt
2005-08-11 17:10                   ` linux-os (Dick Johnson)
2005-08-11 17:26                     ` Steven Rostedt
2005-08-11 17:33                       ` Steven Rostedt
2005-08-11 17:57                         ` linux-os (Dick Johnson)
2005-08-11 17:59                         ` Zachary Amsden
2005-08-11 18:17                           ` Steven Rostedt
2005-08-11 19:58                             ` Zachary Amsden
2005-08-11 20:04                               ` Steven Rostedt
2005-08-12 19:30                           ` Jan Engelhardt
2005-08-11 17:46                       ` linux-os (Dick Johnson)
2005-08-11 18:11                         ` Steven Rostedt
2005-08-11 18:21                           ` linux-os (Dick Johnson)
2005-08-11 19:00                             ` Steven Rostedt
2005-08-11 20:39                           ` Zwane Mwaikambo
2005-08-12 11:29                             ` Bodo Eggert
2005-08-11 17:18                   ` Steven Rostedt
2005-08-12  5:04                     ` Jeff Carr
2005-08-12  5:30                       ` Coywolf Qi Hunt
2005-08-12 10:34                       ` Steven Rostedt
2005-08-12 10:40                       ` Steven Rostedt
2005-08-11 14:05   ` Steven Rostedt
2005-08-11 23:25     ` Bodo Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1123768476.17269.46.camel@localhost.localdomain \
    --to=rostedt@goodmis.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ukil_a@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox