Hello,

I am facing a problem while creating more than one rt-threads in my program.
On some machines it is consistantly giving kernel panic result. Some other
machines it does not give any problem and my program works fine.

I would like to know whethere there is any limitation in creating more than
one RT-Threads in a single process. If anyone out there has any idea, can
you please let me know where I am doing wrong?

Both the machines have rtl-3.1 and kernel version 2.4.4.

Here I am attaching the small sample program I have written. I have modified
the same hello.c in the examples that come along with the rt-linux
installation and am using the same Makefile for creating the module and
inserting it.

Thanks much in advance for your help.

Regards,
Ravi

/* ===
hello.c
====*/


#include <rtl.h>
#include <time.h>
#include <pthread.h>
#include <linux/malloc.h>

pthread_t thread;
pthread_t thread1;
pthread_attr_t attr;
struct sched_param schedParam;

char *name = NULL;

void * start_routine(void *arg)
{
        int cnt = 0;

        pthread_make_periodic_np (pthread_self(), gethrtime(), 500000000);

        while (1) {
                pthread_wait_np ();
                if(cnt %10 == 0)
                {
                        cnt = 0;
                        rtl_printf("I'm here; my arg is %x\n", (unsigned)
arg);
                }
                cnt++;
        }
        return 0;
}
void * start_routine1(void *arg)
{
        int cnt = 0;
        char *name = "Test program";

        pthread_make_periodic_np (pthread_self(), gethrtime(), 500000000);

        while (1) {
                pthread_wait_np ();
                if(cnt % 20 == 0)
                {
                        rtl_printf("in thread 2 \n");
                        rtl_printf("my arg is %x\n", (unsigned) arg);
                        if(name != NULL)
                                rtl_printf(" Name = %s \n", name);
                        cnt = 0;
                }
                cnt++;
        }
        return 0;
}

int init_module(void) {
        int ret = 0;
        pthread_attr_init(&attr);
        schedParam.sched_priority = 2;
        pthread_attr_setschedparam(&attr, &schedParam);
        ret = pthread_create (&thread, &attr, start_routine, 0);

        pthread_attr_init(&attr);
        schedParam.sched_priority = 1;
        pthread_attr_setschedparam(&attr, &schedParam);
        ret = pthread_create (&thread1, &attr, start_routine1, 0);
        return ret;
}

void cleanup_module(void) {
        pthread_delete_np (thread);
        pthread_delete_np (thread1);
}

/* ================
end of the hello.c program
================== */
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/

Reply via email to