Re: Simple question about CPUs and processes

From: Robert Watson (rwatson_at_FreeBSD.org)
Date: 01/31/05

  • Next message: Ryan Sommers: "Re: Simple question about CPUs and processes"
    Date: Mon, 31 Jan 2005 15:00:24 +0000 (GMT)
    To: security@revolutionsp.com
    
    

    On Mon, 31 Jan 2005 security@revolutionsp.com wrote:

    > I'd like some insight on the following; Me and a friend were discussing
    > tech stuff and he said that, when using dual (or more) CPU systems, it
    > is the hardware itself (and alone) choosing which CPU will execute this
    > or that process.
    >
    > But I think it is the OS kernel (FreeBSD in this case) and the SMP
    > implementation that decide this process should live in CPU0 or CPU1, ie
    > it's FreeBSD itself choosing on what CPU a process will reside in.

    This is basically the case on hardware supported by FreeBSD: the OS
    scheduler decides where to place processes in order, ideally, to maximize
    performance. The hardware will affect the performance, however, due to
    some systems supporting non-uniform access to chunks of memory depending
    on the CPU the code runs on, the contents of the cache, etc. Often, the
    job of the OS scheduler isn't simply to decide on fair or desirable run
    orders based on priority, but where best to run the process/thread based
    on where it's run recently, clusters of related CPUs, etc. These issues
    are becoming more important on i386-based systems with the advent of
    hyper-threading, dual-core chips, amd64 NUMA, etc. In the end, though,
    the decision (good or bad) will be made by the OS.

    There is two exceptions regarding execution:

    - The hardware may be involved in deciding which CPU will receive
      interrupts -- for example, it may round-robin deliver timer interrupts
      to CPUs to attempt to help manage interrupt load. This will cause an
      interrupt handler to run on the CPU selected by the hardware, at which
      point the OS can decide whether it wants to process the interrupt on
      that CPU, or forward it to another for processing.

    - There are some activities that must be performed on specific processors.
      For example, the boot necessarily starts out on the boot processor (BP).
      It turns out that many Intel or Intel-like systems get quite unhappy if
      system shutdown is initiated from a non-boot processor, so FreeBSD also
      arranges for the boot processor to issue the power down call into ACPI
      on platforms running ACPI. The hardware isn't choosing where to run
      this code per se, but if you pick the wrong one the hardware won't like
      you :-).

    Hope this is helpful,

    Robert N M Watson

    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"


  • Next message: Ryan Sommers: "Re: Simple question about CPUs and processes"

    Relevant Pages

    • Re: [PATCH] I/O APIC: Timer through 8259A revamp
      ... the fallback path was meant to be used with hardware suffering from ... interrupt genuinely arrives through multiple I/O APIC inputs, ... the i386SL was *the* power-saving Intel CPU when the i82489DX was ... Trouble on Linux is that RTC doesn't support any of the traditional HZ ...
      (Linux-Kernel)
    • Re: How to develop a random number generation device
      ... single shared CPU; much less, in fact, since irrevelant interrupts, ... probably through shared memory and semaphores. ... switches are a reliability issue - processors don't have problems with them. ... If you shift the complexity to hardware, you'd get hardware that is expensive and buggy. ...
      (sci.electronics.design)
    • Re: Starting Windows 2000 hangs on new install.
      ... There might also be other mobo updated drivers. ... I've heard it said that winme is less 'hardware picky' than win2k ... > || Kevin. ... trying to return the CPU, but I'd need to show that it is faulty ...
      (microsoft.public.win2000.setup)
    • Re: Starting Windows 2000 hangs on new install.
      ... I mention BT merely as an example of my experience with a piece of hardware ... > CPU, but I'd need to show that it is faulty first. ... If you recently purchased mobo or cpu are you able to ... > || Kevin. ...
      (microsoft.public.win2000.setup)
    • RE: 70% CPU Usage Due to Hardware Interrupt Conflicts
      ... >> the CPU (also as measured by Windows Task Manager). ... >> apparent hardware conflicts, but a process management tool (Process Manager ... >> IRQ 10: ...
      (microsoft.public.windowsxp.general)