Hi all. Below is my hacked up version of reserve_cpu.c from
examples/misc. I am running rtl-3.0-pre10 with Linux 2.4.0-test1. I have a
dual P-II, 400 Mhz, Micron system (nightshade motherboard). However, when
I run the code below my system hangs -- this happens even if I just
allocate a single CPU.

        My overall goal is effectively allocate all CPUs -- meaning all
threads are NOT periodic, thus RTLinux is not giving up a single CPU cycle
to Linux -- is such a thing possible? I have head this causing problems,
but I do not quite understand why on a stand alone system (i.e., no NFS or
other multimedia device are running -- just a hard disk, ram, CPU and
console -- that is all I need) -- I would of course like Linux to come
back once my multithreaded program is complete.

        Any help would be most appreciated.     

                        Thanks,
                        Chris

--------------------------------------------------------------------
Christopher D. Carothers

Assistant Professor
Department of Computer Science         
Rensselaer Polytechnic Institute
110 8th Street
Troy, New York 12180-3590

e-mail: [EMAIL PROTECTED]
web page: www.cs.rpi.edu/~chrisc
phone: (518) 276-2930 
fax: (518) 276-4033
--------------------------------------------------------------------

#include <rtl.h>
#include <pthread.h>

#include <rtl_conf.h>
#ifndef CONFIG_RTL_SUSPEND_LINUX
#error CONFIG_RTL_SUSPEND_LINUX not enabled
#endif

pthread_t thread;
#define NUMBER_OF_WAITS 10000
#define NUMBER_OF_OUTER_ITERATIONS 500
#define NUMBER_OF_INNER_ITERATIONS 10000

volatile int start0=0;
volatile int start1=0;

void * start_routine(void *arg)
{
  int i,j;
  hrtime_t start;

  rtl_printf("RTL Reserve_cpu thread starts on cpu %d\n",
             hw_smp_processor_id());

  if( hw_smp_processor_id() == 0 )
    start0 = 1;
  else if( hw_smp_processor_id() == 1 )
    start1 = 1;
  else
    {
      rtl_printf("RTL error: invalid cpu id %d\n", hw_smp_processor_id());
      return 0;
    }

  //  i = 0;
  //  while( start0 == 0 && start1 == 0 )
  //    i++;
  
  rtl_printf("start RTLinux reserve_cpu demo: numcpus=%d\n",
             smp_num_cpus);
  
  for(j=0; j < NUMBER_OF_OUTER_ITERATIONS; j++)
    {
      for(i=0; i < NUMBER_OF_INNER_ITERATIONS; i++)
        {
          start = gethrtime();
          while( gethrtime() - start < 50000 )
            start++;
        }
      rtl_printf("RESERVE Demo: itr = %d, cpu = %d ",j, hw_smp_processor_id());
    }
  rtl_printf("RTLinux RESERVE DEMO: end numcpus=%d\n",smp_num_cpus);
  return 0;
}

int init_module(void) 
{
  pthread_attr_t attr;

  pthread_attr_init (&attr);
  pthread_attr_setcpu_np(&attr, 1);
  pthread_create (&thread, &attr, start_routine, 0);
  // pthread_attr_setcpu_np(&attr, 0);
  // return pthread_create (&thread, &attr, start_routine, 0);
  return 0;
}

void cleanup_module(void) 
{
  rtl_printf("RTLinux RESERVE DEMO: cleanup numcpus=%d\n",smp_num_cpus); 
}


-- [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/rtlinux/

Reply via email to