pthreads scheduling problem on Linux

From: Malapati Narasimha Raju (nraju_99@hotmail.com)
Date: Wed Jun 14 2000 - 11:07:35 EST


Hi all

Im not really sure whether my question fits into this category or
not. Since I did't find any relevent section for pthreads under Linux
category Im sending my question to this list.

My problem is related to pthreads scheduling. I wrote a small program using
scheduling policy function. Seems the function "pthread_attr_setschedpolicy"
is not working, because Im not able see printf statement's output on
stdout(that means it is not entering the function func() at all). How ever
If I remove the statement "pthread_attr_setschedpolicy(&custom_sched_attr,
SCHED_FIFO);", I am able see the output on stdout.

Can some body throw some light about this situation. As my project is fully
depending on threads scheduling, early reply is highly appreciated.

As I am not in the mailing list please send me an e-mail at
"nraju_99@hotmail.com".

Here is the code.

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

void func(void)
{
        printf("Im in Function func \n");
}

main()
{
        pthread_t thread;
        pthread_attr_t custom_sched_attr;
        struct sched_param fifo_param;

        /* Initialize the attribute object */
        pthread_attr_init(&custom_sched_attr);

        /* Set the scheduling policy */
        pthread_attr_setschedpolicy(&custom_sched_attr, SCHED_FIFO);

        /* Set the scheduling priority */
        fifo_param.sched_priority = 99;
        pthread_attr_setschedparam(&custom_sched_attr, &fifo_param);

        /* Create a thread */
        pthread_create(&thread, &custom_sched_attr, (void *) func, NULL);

        /* Wait for thread completion */
        pthread_join(thread, NULL);
}

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Jun 15 2000 - 21:00:32 EST