Re: User/Kernel Level Threads

From: John R (reguera_at_nospam.leavemealone.zk3.dec.com)
Date: 03/03/04

  • Next message: David Cutter: "Speeding up NetRain response times for 5.1."
    Date: Wed, 03 Mar 2004 17:30:38 GMT
    
    

    I think we need to define a few things:
       
    Since we are in the TRU64 newsgroup, lets deal with Tru64
    specifically.

      Tru64 kernel is based on the Mach model

    User threads have 2 possibilities:
      PCS threads (many to one model)
      SCS threads (one to one model)

    PCS threads is the default configuration

    On 25 Feb 2004 13:11:47 -0800, anne_dolly00@yahoo.co.uk (Anne) wrote:

    >Hello,
    >
    >I am confused about User level Thread /Kernel Level Threads. Could you
    >please look at my following questions? Many thanks for your time
    >
    >0- With Kernel Level thread, will the thread run on Kernel mode?
    >that's what i have read, thread (user) code so can run on the kernel
    >space, that's look very dangerous for me!
    >does thread kernel mode means really that the threads code is mapped
    >on the kernel space?

    No, the user level threads will run in user space, independent of the
    threads model used.
     
    >
    >
    >1- Java for instance provides a package to manage Threads at the user
    >level. If instead a user wants to implement threads at the kernel
    >level which package should he/she use when working on
    >
    >1- Windows NT
    >
    >2- Linux
    >
    >
    >
    >2- If the user writes multithreaded code using user level library,
    >will these threads be automatically mapped (one to one or many to
    >many) to kernel level threads? Or it is up to the user to instruct
    >this, if yes how?

    It is up to the user to implement the threads as they want. We do
    not stop the user from shooting himself in the foot. As already
    mentioned, PCS (many to one) is the default configuration on Tru64
    Unix. See pthread_attr_setscope()

    >
    >3- If kernel level threads are supported, will the operating
    >system schedule processes first and then threads or schedule directly
    >threads. If the latter case is assumed some processes may stave and
    >others substantially favoured!

    Using PCS threads, scheduling is done in the threads library
    Using SCS threads, scheduling is done by the kernel
    There is always a chance of starvation, independent of the scheduling
    policy. We strongly recommend that the user not attempt to use
    policies and priorites to define application behavior.

      
    >
    >4- When threads are created, each thread ll be associated with a
    >dedicated stack within the same process's address space. What
    >mechanism and policy is followed to protect each thread stack from the
    >other

     There is a guard page (with a yellow zone) around each stack.
    I will restate that we do nothing to stop you from shooting yourself
    in the foot. You could set the deafullt stack size such that you
    will have stack overflow. Determining optimum stack size can take
    some tweaking and adjusting.

    Starting in Version 5.0, for threads that accept the default stack
    address attribute, the Threads Library allocates a thread's writable
    stack area from uncommitted virtual memory, then commits predefined
    increments of the writable stack area to the thread only as it is
    needed. The stack's corresponding backing store is also reserved
    incrementally as the stack is committed. In this way, no more backing
    store is reserved than the stack actually requires.

    Because Tru64 UNIX 5.0 does not commit backing store (or physical
    pages) for stacks until the pages are used by the program, the default
    stack size has been increased. The previous default of about 24Kb (3
    pages) has been increased to 5Mb.

    John Reguera


  • Next message: David Cutter: "Speeding up NetRain response times for 5.1."

    Relevant Pages

    • [Full-disclosure] PHRACK 64: ATTACKING THE CORE
      ... - The Slab Allocator ... - Slab overflow exploiting: ... - Forcing a kernel path to sleep ... - Stack Frame Flow Recovery ...
      (Full-Disclosure)
    • Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
      ... stack usages for you is that they contain a 'cpumask_t' on the stack. ... We can enable MAXSMP and raise the CPU limits some time in the future. ... not accept a specially built kernel, but only a kernel that has been ... know how extensively these distributions test and certify for many known ...
      (Linux-Kernel)
    • Re: Interrupt context...
      ... > gone through most of the posts on interrupt in usenet. ... > kernel stack and ISR is executed. ... More may be saved depending on the architecture. ... Here the kernel have assembler code to save all general ...
      (comp.os.linux.development.system)
    • Re: The Linux Staging tree, what it is and is not.
      ... if you compromize them and write the wrong ones to the stack, ... Load two user space fieldbus stacks on the same network card (remembering ... right, but that's the same, no matter if it runs in kernel or user ... need an objdict API to userspace...? ...
      (Linux-Kernel)
    • Re: The Linux Staging tree, what it is and is not.
      ... Load two user space fieldbus stacks on the same network card (remembering ... need an objdict API to userspace...? ... It depends where you split the stack between kernel and user space. ...
      (Linux-Kernel)