Re: task switching

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

 



On Wed, Jan 16, 2002 at 02:48:25PM -0500, Chris Wright wrote:
> i need something that is nearer to 1/1000th of a second resolution.

Sounds like you need the POSIX real-time stuff. sigaction, nanosleep,
and similar.

> however, i am curious:  if you have a task that runs for half a jiffy,
> then get blocked, does the kernel switch to a new task immediatly, or
> does it wait for the jiffy to expire before continuing (wasting half a
> jiffy).

The Linux kernel can switch to another task when exiting kernel mode and
when it blocks in kernel code. This is the HZ (100 per second on x86 by
default) interrupt, real-time-clock interrupts, keyboard, mouse, NIC,
etc interrupts. This is also blocking while waiting for page faults,
reading/writing to disk that isn't in the buffer cache yet, reading from
terminals .. all the things that can cause a process to block. :)

The vmstat program can give you some details on this..
$ vmstat 1
   procs                      memory    swap          io     system         cpu
 r  b  w   swpd   free   buff  cache  si  so    bi    bo   in    cs  us  sy  id
 1  0  0  73268   1408   8352 240944   0   0     9     8    5    10  18   1  25
 1  0  0  73268   1404   8352 240944   0   0     0     0  157   698   2   1  97
 1  0  0  73268   1408   8352 240944   0   0     0     0  178   771   1   0  99
 0  0  0  73268   1404   8352 240944   0   0     0     0  188   823   0   1  99

(I sure hope that didn't wrap...)

Note the 'cs' column .. it shows context switches per second, while 'in'
shows interrupts per second.

Cheers ;)

-- 
People who separate manpages from the programs
they document would steal sheep.  -- apologies to Goudy

Attachment: pgp00018.pgp
Description: PGP signature


[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