# S3C2440A strange perfomance issue



## vifits (May 12, 2011)

Hi!

I have installed FreeBSD on a GT2440 ARM9 development board (S3C2440A SoC).

I'm trying to compile the following simple code:


```
%cat test.c
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
        unsigned int area_size = 1024*1024;
        unsigned int *p = (unsigned int *)malloc(area_size * sizeof(unsigned int));
        if(p){
                unsigned int cnt = 32;
                while(cnt > 0){
                        unsigned int i = 0;
                        while(i < area_size){
                                p[i] = i;
                                i++;
                        }
                        cnt--;
                }
                free(p);
        }else{
                printf("memory allocation failed.\n");
        }
        return(0);
}

%cc -O0 -o test test.c
```

and execute it:


```
%/usr/bin/time -l ./test
      120.16 real       119.44 user         0.16 sys
      4824  maximum resident set size
         4  average shared memory size
       963  average unshared data size
       128  average unshared stack size
      1101  page reclaims
         0  page faults
         0  swaps
         0  block input operations
         0  block output operations
         1  messages sent
         0  messages received
         0  signals received
         2  voluntary context switches
     12177  involuntary context switches
```

Time of execution is over 120 seconds, but after a system reboot:


```
%/usr/bin/time -l ./test
        2.85 real         2.55 user         0.25 sys
      4824  maximum resident set size
         4  average shared memory size
       953  average unshared data size
       129  average unshared stack size
      1101  page reclaims
         0  page faults
         0  swaps
         0  block input operations
         0  block output operations
         1  messages sent
         0  messages received
         0  signals received
         3  voluntary context switches
       292  involuntary context switches
```

execution time is 2.85(!) sec, but that's not all!


```
%cat test > /dev/null

%/usr/bin/time -l ./test
      120.40 real       119.51 user         0.23 sys
      4824  maximum resident set size
         4  average shared memory size
       963  average unshared data size
       128  average unshared stack size
      1101  page reclaims
         0  page faults
         0  swaps
         0  block input operations
         0  block output operations
         1  messages sent
         0  messages received
         0  signals received
         2  voluntary context switches
     12201  involuntary context switches
```

Once the file has been opened for reading (*cat test > /dev/null*), execution time again increased to 120 seconds (until the next reboot).

What is it?


----------

