Re: Wait Queues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dinesh Ahuja wrote:

> Thanks for your replying. Still I am not clear in a
> below output, that If we are loading shared object
> librt in a memory map, then why are we calling unmmap
> before we make a call to the functions exposed by
> litrt e.x rt_sigaction.

The call to unmap() may simply be to free unused heap memory.  Without
reading the source code to the dynamic linker or the C runtime library,
I can't say for sure, but you can be certain that no shared library is
being unmapped before it is used.

> Could you explain at what time a context switch takes
> place from user space to a kernel space.

A context switch from user-space to kernel-space happens when an
interrupt happens.  There are two kinds of interrupts: software
interrupts (used for system calls) and hardware interrupts.  A common
hardware interrupt is the clock interrupt, which happens many times per
second and (among other things) gives the kernel a chance to preempt a
process that is hogging the CPU.

> The function
> call gettimeofday is being executed in a user space as
> it is not a kernel sys call

It is a system call.  Type "man gettimeofday" and notice the "(2)"
following the function name.  That means it is a system call.

> so at what point a switch
> takes place. How is responsible for switching from
> user to kernel and vice versa and I would like to see
> that code.

All system calls have corresponding functions in the C runtime library.
When your program calls one, such as read(), the function in the C
library (named "read") loads the corresponding system call number into a
register (along with other arguments it received from the user program)
and then executes a machine instruction that causes a software
interrupt.  The CPU responds to a software interrupt by switching
context to the kernel.

On an Intel x86 CPU, the software interrupt instruction is: INT 0x80.
For for info, see:

  http://www.tldp.org/LDP/khg/HyperNews/get/syscall/syscall86.html

Hope this helps.
--
Francis Litterio
franl <at> world . std . com


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux