msleep - Linux

This is a discussion on msleep - Linux ; Hi All, Inside a kernel module, an ioctl implementation calls the "msleep(5)" function. My question is during the 5 msecs that msleep is called, would the thread that has called the ioctl would go to sleep or entire process? Many ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: msleep

  1. msleep


    Hi All,
    Inside a kernel module, an ioctl implementation calls the "msleep(5)"
    function. My question is during the 5 msecs that msleep is called,
    would the thread that has called the ioctl would go to sleep or entire
    process?

    Many thanks in advance,
    Bizhan

  2. Re: msleep

    On Oct 14, 2:26*am, Mona wrote:

    > Inside a kernel module, an ioctl implementation calls the "msleep(5)"
    > function. My question is during the 5 msecs that msleep is called,
    > would the thread that has called the ioctl would go to sleep or entire
    > process?


    The thread.

    DS

  3. Re: msleep

    On Oct 14, 2:26*pm, Mona wrote:
    > Hi All,
    > Inside a kernel module, an ioctl implementation calls the "msleep(5)"
    > function. My question is during the 5 msecs that msleep is called,
    > would the thread that has called the ioctl would go to sleep or entire
    > process?
    >
    > Many thanks in advance,
    > Bizhan


    The thread which calls the routine msleep() will go for sleep. In
    linux all threads are handled as process in terms of process related
    data structure. That is for each and every thread will be assigned a
    task_struct will be created. So the time slice will be applied to the
    thread instead of the process.
    So in this case if you have "n" number of threads in that process and
    when a thread is calling msleep it will be put to sleep. If no other
    thread/process is available to schedule there is a chance likely that
    the other n-1 threads of your process will get scheduled.

    Hope this clarifies.
    Mohan.

  4. Re: msleep

    Mohan_Gunasekaran writes:

    [...]

    > The thread which calls the routine msleep() will go for sleep. In
    > linux all threads are handled as process in terms of process related
    > data structure. That is for each and every thread will be assigned a
    > task_struct will be created.


    The most commonly used threading libraries on Linux do 1:1
    threading. The kernel schedules only 'threads of execution'. These
    belong to some set of processes, still being defined as 'collection of
    system ressources plus n threads of execution'. There is no such thing
    as a 'schedulable process' in Linux and there hasn't been one since
    the clone system call was invented. Before this happened (that's
    before Linux 2.0), kernel-supported multithreading was at all
    impossible on Linux. This is different from other operating systems,
    for instance, Solaris, which inherited the traditional
    UNIX(*)-implementation of kernel-schedulable processes (among other
    things, a proc-structure and a 'u area'). In order to support
    SMP-aware multithreading, a separate kernel-level abstraction, a
    so-called 'LWP' (light-weight process) was invented, which did not
    come with the baggage of the existing support for single-threaded
    processes attached.

+ Reply to Thread