This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

wakeup call. smp patch previous to applying the hal/sparc patches


It's a while ago that I posted the hal/sparc patches to be applied.
Andrew Lunn wrote that Nick has to aprove the kernel and i386 patches
before the sparc one can move in, so I compiled a little thinking guide
so that it gets clear that the patches, if applied, do not alter any
of the code. I hope that speeds it up.
-- Greetings Konrad

There are lines of three patches to the kernel:
1.)
original: HAL_SMP_CPU_TYPE cpu = (i + cpu_this) % cpu_count;
patched : HAL_SMP_CPU_TYPE cpu = HAL_SMP_CPU_COUNT2IDX ( (i + HAL_SMP_CPU_IDX2COUNT( cpu_this ) ) % cpu_count );


i386 : resolving macros:

            #define HAL_SMP_CPU_COUNT2IDX(n)  (n)
            #define HAL_SMP_CPU_IDX2COUNT(n)  (n)

will resolve to:

HAL_SMP_CPU_TYPE cpu = (i + cpu_this) % cpu_count;

=> same as before

 2.)
  original: for( cpu = 0; cpu < cpu_count; cpu++ )
  patched : int c; for( c = 0; c < cpu_count; c++ ) { \
                 cpu = HAL_SMP_CPU_COUNT2IDX(c);

i386 : resolving macros:

#define HAL_SMP_CPU_COUNT2IDX(n) (n)

will resolve to:

            int c; for( c = 0; c < cpu_count; c++ ) { \
                 cpu = c;

=> same semantic as before

 3.)
  original: for( cpu = 0; cpu < CYG_KERNEL_CPU_COUNT(); cpu++ )
  patched : for( cpu = 0; cpu < CYG_KERNEL_CPU_START_COUNT(); cpu++ )
  i386    : resolving macros:

            #define CYG_KERNEL_CPU_COUNT()    HAL_SMP_CPU_COUNT()
            #define HAL_SMP_CPU_START_COUNT() HAL_SMP_CPU_COUNT()

original resolved to:

for( cpu = 0; cpu < HAL_SMP_CPU_COUNT(); cpu++ )

            pathced resolves to:
            for( cpu = 0; cpu < HAL_SMP_CPU_COUNT(); cpu++ )

=> asme as before


diff -Naur ecos-rep-ori/packages/hal/i386/arch/current/include/hal_smp.h ecos-rep/packages/hal/i386/arch/current/include/hal_smp.h
--- ecos-rep-ori/packages/hal/i386/arch/current/include/hal_smp.h	2005-07-26 17:57:15.000000000 +0200
+++ ecos-rep/packages/hal/i386/arch/current/include/hal_smp.h	2005-07-26 18:08:48.000000000 +0200
@@ -156,6 +156,12 @@
 
 #define HAL_SMP_CPU_COUNT()     cyg_hal_smp_cpu_count
 
+#define HAL_SMP_CPU_START_COUNT() HAL_SMP_CPU_COUNT()
+     
+#define HAL_SMP_CPU_COUNT2IDX(n)  (n)
+
+#define HAL_SMP_CPU_IDX2COUNT(n)  (n)
+
 #define HAL_SMP_CPU_THIS()                      \
 ({                                              \
     HAL_SMP_CPU_TYPE __id;                      \
diff -Naur -x tests -x tests_smp -x kernel.cdl ecos-rep-ori/packages/kernel/current/include/smp.hxx ecos-rep/packages/kernel/current/include/smp.hxx
--- ecos-rep-ori/packages/kernel/current/include/smp.hxx	2005-07-26 17:57:21.000000000 +0200
+++ ecos-rep/packages/kernel/current/include/smp.hxx	2005-07-26 18:08:48.000000000 +0200
@@ -88,6 +88,8 @@
 
 #define CYG_KERNEL_CPU_COUNT()          HAL_SMP_CPU_COUNT()
 
+#define CYG_KERNEL_CPU_START_COUNT()    HAL_SMP_CPU_START_COUNT()
+
 #define CYG_KERNEL_CPU_THIS()           HAL_SMP_CPU_THIS()
 
 #define CYG_KERNEL_CPU_NONE             HAL_SMP_CPU_NONE
diff -Naur -x tests -x tests_smp -x kernel.cdl ecos-rep-ori/packages/kernel/current/src/sched/mlqueue.cxx ecos-rep/packages/kernel/current/src/sched/mlqueue.cxx
--- ecos-rep-ori/packages/kernel/current/src/sched/mlqueue.cxx	2005-07-26 17:57:21.000000000 +0200
+++ ecos-rep/packages/kernel/current/src/sched/mlqueue.cxx	2005-07-26 18:08:48.000000000 +0200
@@ -350,7 +350,8 @@
 
     for(int i = 0; i < cpu_count; i++)
     {
-        HAL_SMP_CPU_TYPE cpu = (i + cpu_this) % cpu_count;
+        HAL_SMP_CPU_TYPE cpu =
+          HAL_SMP_CPU_COUNT2IDX ( (i + HAL_SMP_CPU_IDX2COUNT( cpu_this ) ) % cpu_count );
        
         // If a CPU is not already marked for rescheduling, and its
         // current thread is of lower priority than _thread_, then
@@ -464,12 +465,15 @@
 
 #ifdef CYGPKG_KERNEL_SMP_SUPPORT
 
+    int c;
     HAL_SMP_CPU_TYPE cpu;
     HAL_SMP_CPU_TYPE cpu_count = CYG_KERNEL_CPU_COUNT();
     HAL_SMP_CPU_TYPE cpu_this = CYG_KERNEL_CPU_THIS();
     
-    for( cpu = 0; cpu < cpu_count; cpu++ )
+    for( c = 0; c < cpu_count; c++ )
     {
+        cpu = HAL_SMP_CPU_COUNT2IDX(c);
+      
         if( --timeslice_count[cpu] == 0 )
             if( cpu == cpu_this )
                 timeslice_cpu();
diff -Naur -x tests -x tests_smp -x kernel.cdl ecos-rep-ori/packages/kernel/current/src/sched/sched.cxx ecos-rep/packages/kernel/current/src/sched/sched.cxx
--- ecos-rep-ori/packages/kernel/current/src/sched/sched.cxx	2005-07-26 17:57:21.000000000 +0200
+++ ecos-rep/packages/kernel/current/src/sched/sched.cxx	2005-07-26 18:08:48.000000000 +0200
@@ -321,7 +321,7 @@
 
     HAL_SMP_CPU_TYPE cpu;
     
-    for( cpu = 0; cpu < CYG_KERNEL_CPU_COUNT(); cpu++ )
+    for( cpu = 0; cpu < CYG_KERNEL_CPU_START_COUNT(); cpu++ )
     {
         // Don't start this CPU, it is running already!
         if( cpu == CYG_KERNEL_CPU_THIS() )

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]