linuxthreads and scheduling

linuxthreads and scheduling

Post by Stuart Hughe » Wed, 13 May 1998 04:00:00



I just got David Butenhof's programming with POSIX threads which I
highly recommend.  I'm having a problem getting some of the examples to
run.  Although the calls to set the scheduling to FIFO don't return
errors, when I do a pthread_getschedparam nothing seems to have changed.

I am running as root, on a redhat 4.2 that has been upgraded to kernel
2.0.33 and libc 5.4.44.

I have simplified the example from the book even further (see below), I
build the example using:

cc -DPOSIX -D_REENTRANT -g -Wall sched.c -o sched -lpthread

running it gives:


initial: thread_routine running at OTHER/0
pthread_setschedparam: thread_routine running at OTHER/0

Anyone got any ideas

TIA

Stuart Hughes

-------------------- example code
------------------------------------------

#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>

void err_exit(char *msg)
{
    fprintf(stderr,"%s : %s\n", msg, strerror(errno));
    abort();

Quote:}

void print_sched_info(char *msg)
{
    int my_policy;
    struct sched_param my_param;

    if(pthread_getschedparam( pthread_self(), &my_policy, &my_param))
        err_exit("pthread_getschedparam");

    printf ("%s: thread_routine running at %s/%d\n", msg,
        (my_policy == SCHED_FIFO ? "FIFO"
            : (my_policy == SCHED_RR ? "RR"
            : (my_policy == SCHED_OTHER ? "OTHER"
            : "unknown"))),
        my_param.sched_priority);

Quote:}

void main()
{
    int policy;
    struct sched_param param;

    // print initial policy/priority
    print_sched_info("initial");

    // set policy and priory RR/50
    policy = SCHED_RR;
    param.sched_priority = 50;
    if(pthread_setschedparam(pthread_self(), policy, &param))
        err_exit("pthread_setschedparam");

    // print new policy
    print_sched_info("pthread_setschedparam");

Quote:}

 
 
 

linuxthreads and scheduling

Post by Kaz Kylhe » Wed, 13 May 1998 04:00:00




Quote:>I just got David Butenhof's programming with POSIX threads which I
>highly recommend.  I'm having a problem getting some of the examples to
>run.  Although the calls to set the scheduling to FIFO don't return
>errors, when I do a pthread_getschedparam nothing seems to have changed.

>I am running as root, on a redhat 4.2 that has been upgraded to kernel
>2.0.33 and libc 5.4.44.

>I have simplified the example from the book even further (see below), I
>build the example using:

>cc -DPOSIX -D_REENTRANT -g -Wall sched.c -o sched -lpthread

Are you sure you are using LinuxThreads? Redhat 4.2 does not come with
LinuxThreads, and they are not in libc 5.4.44. The <pthread.h>
header file you get is actually for the MIT user-level threads.
You must install LinuxThreads separately.

I'm only asking because you mentioned your kernel and library
versions but not the version of LinuxThreads that you installed.

Also, it's easy to end up using the wrong <pthread.h> header
even if you did install LinuxThreads correctly. Consider
a scenario in which you install LinuxThreads and then
unpack a new libc5 by untarring blindly from the root
directory. It will overwrite the LinuxThreads pthread.h
with its own pthread.h whose datastructures are not
compartible with the LinuxThreads shared lib.

 
 
 

linuxthreads and scheduling

Post by Robert Hyat » Wed, 13 May 1998 04:00:00



: I just got David Butenhof's programming with POSIX threads which I
: highly recommend.  I'm having a problem getting some of the examples to
: run.  Although the calls to set the scheduling to FIFO don't return
: errors, when I do a pthread_getschedparam nothing seems to have changed.

: I am running as root, on a redhat 4.2 that has been upgraded to kernel
: 2.0.33 and libc 5.4.44.

: I have simplified the example from the book even further (see below), I
: build the example using:

: cc -DPOSIX -D_REENTRANT -g -Wall sched.c -o sched -lpthread

None of that stuff is implented.  Linux behaves like you do a
SCOPE_SYSTEM attribute call... that is, threads are kernel
processes, and scheduling is done by the kernel, not by a thread
library...

 
 
 

linuxthreads and scheduling

Post by Kaz Kylhe » Wed, 13 May 1998 04:00:00



Quote:>None of that stuff is implented.  Linux behaves like you do a
>SCOPE_SYSTEM attribute call... that is, threads are kernel
>processes, and scheduling is done by the kernel, not by a thread
>library...

Whether or not the functionality is implemented is irrelevant to whether
or not the parameters can be set and retrieved in the interface.
 
 
 

linuxthreads and scheduling

Post by Nilanjan Bhowmi » Wed, 13 May 1998 04:00:00


In the same note - Can I get something like 'gethrtime' in Linux world ?
( it is there in solaris )

And also gethostbyname_r or all _r functions - anyone ?




> >I just got David Butenhof's programming with POSIX threads which I
> >highly recommend.  I'm having a problem getting some of the examples to
> >run.  Although the calls to set the scheduling to FIFO don't return
> >errors, when I do a pthread_getschedparam nothing seems to have changed.

> >I am running as root, on a redhat 4.2 that has been upgraded to kernel
> >2.0.33 and libc 5.4.44.

> >I have simplified the example from the book even further (see below), I
> >build the example using:

> >cc -DPOSIX -D_REENTRANT -g -Wall sched.c -o sched -lpthread

> Are you sure you are using LinuxThreads? Redhat 4.2 does not come with
> LinuxThreads, and they are not in libc 5.4.44. The <pthread.h>
> header file you get is actually for the MIT user-level threads.
> You must install LinuxThreads separately.

> I'm only asking because you mentioned your kernel and library
> versions but not the version of LinuxThreads that you installed.

> Also, it's easy to end up using the wrong <pthread.h> header
> even if you did install LinuxThreads correctly. Consider
> a scenario in which you install LinuxThreads and then
> unpack a new libc5 by untarring blindly from the root
> directory. It will overwrite the LinuxThreads pthread.h
> with its own pthread.h whose datastructures are not
> compartible with the LinuxThreads shared lib.

 
 
 

linuxthreads and scheduling

Post by Robert Hyat » Thu, 14 May 1998 04:00:00




:>None of that stuff is implented.  Linux behaves like you do a
:>SCOPE_SYSTEM attribute call... that is, threads are kernel
:>processes, and scheduling is done by the kernel, not by a thread
:>library...

: Whether or not the functionality is implemented is irrelevant to whether
: or not the parameters can be set and retrieved in the interface.

I haven't looked at the pthread source recently, but I'd *hope* that
it does... IE I would not want to attempt to set something, then query
it and have it tell me it did set it, only to find it not really set
because it isn't supported...

But I have the pthread source tucked away so I'll check..

--
Robert Hyatt                    Computer and Information Sciences

(205) 934-2213                  115A Campbell Hall, UAB Station
(205) 934-5473 FAX              Birmingham, AL 35294-1170

 
 
 

linuxthreads and scheduling

Post by Robert Hyat » Thu, 14 May 1998 04:00:00



: In the same note - Can I get something like 'gethrtime' in Linux world ?
: ( it is there in solaris )

: And also gethostbyname_r or all _r functions - anyone ?

Don't these come in as part of the pthread stuff?  Although I don't think
you need them under glibc 2...

--
Robert Hyatt                    Computer and Information Sciences

(205) 934-2213                  115A Campbell Hall, UAB Station
(205) 934-5473 FAX              Birmingham, AL 35294-1170

 
 
 

linuxthreads and scheduling

Post by Xavier Lero » Thu, 14 May 1998 04:00:00



> I just got David Butenhof's programming with POSIX threads which I
> highly recommend.  I'm having a problem getting some of the examples to
> run.  Although the calls to set the scheduling to FIFO don't return
> errors, when I do a pthread_getschedparam nothing seems to have changed.

You're probably using LinuxThreads 0.5 on a x86 processor.  This
version has a bug in an asm wrapper that causes pthread_setschedparam
to do nothing.  Your program works fine under LinuxThreads 0.7.

Quote:> I am running as root, on a redhat 4.2 that has been upgraded to kernel
> 2.0.33 and libc 5.4.44.

The best thing to do is to upgrade to RedHat 5.0, which has much
better thread support (glibc 2 and LinuxThreads 0.7).  If you want to
stay with libc 5, you can still find a more recent version of
LinuxThreads at
ftp://ftp.inria.fr/INRIA/Projects/cristal/Xavier.Leroy/linuxthreads.t...

- Xavier Leroy

--

This is a protection against junk mail. Apologies for the inconvenience.
Home page: http://pauillac.inria.fr/~xleroy/

 
 
 

1. linuxthreads and scheduling

Thanks to everyone for their help.

Upgrading to the latest version of linuxpthreads version 0.7, made
everything work fine, as Xavier suggested.

I would like to upgrade to redhat 5, but friends who already have have
found some problems with it (clock running fast, old code not
compiling).  Is it worth waiting for a later redhat ??

I would have replied in the proper way to this message, but somehow my
news server/reader missed your replies (I saw them on deja news)

Thanks

Stuart Hughes

2. ATCA blade and interrupts

3. Matrox Mystique ands X.

4. Reading is much more interesting than TV (1665/1708)

5. LinuxThreads+signals => SIGSEGV in system call?

6. Trouble with Laserjet IIIsi, duplex option

7. linuxthread manager and SIGINT

8. xv 3.10a with PNG support working in Solaris?

9. Status of linuxthreads

10. XNextEvent and LinuxThreads

11. LinuxThreads???

12. <defuct> and linuxthread ( a bit long)

13. LinuxThreads