differents in normal or in superuser mode ?

Hi Community !

I try to detect the data rate of Message Passing , by counting bytes on both Versions
of QNX ( 4.25 and 6.21) on the same PC. Problem is I’am detecting in QNX4 different data rates in normal Mode and in root (Superuser) mode. The data rate in normal mode is much higher and shows non linear behavior in bigger blocksize.

What’s the reason for this?

Thank you !!!

Could you post your code?

Thank You mario


#include <stdio.h> /NULL/
#include <sys/kernel.h> /send(), receive(), reply()/
#include <signal.h> /SIGINT,SIGALRM,SIGUSR1/
#include <errno.h> /errno/
#include <stdlib.h> /EXIT_FAILURE, EXIT_SUCCESS/

#define BLOCKSIZE 1024
#define SECS 15

void sigh();

void alarmh();

int flag = 0;

long counter = 0;
pid_t npid = 0;

int main( void )
{
char string[BLOCKSIZE + 1];
int i = 0;

/* String bilden*/
while( i <= BLOCKSIZE - 1 )
    string[i++] = 'x'; 

string[BLOCKSIZE] = '\0';

signal(SIGINT, sigh);

if( npid = fork() ) // Parent
    {
    signal(SIGALRM, alarmh);
    alarm(SECS);

    while( 1 )
        {
        if( flag == 0 )
            {
            if( Send(npid, string, NULL, sizeof(string), NULL) == -1 )
                {
                printf("Error Send() \n");
                printf("Error: %s\n", strerror(errno));
                return (EXIT_FAILURE);
                }

            counter++; 
            }
        }
    }
else
    { // Kindprozess
    while( 1 )
        {
        if( flag == 0 )
            {
            if( (npid = Receive(0, string, sizeof(string))) == -1 )
                {
                printf("Error Receive() \n");
                printf("Error : %s\n", strerror(errno));
                return (EXIT_FAILURE);
                }
            else
                {
                if( Reply(npid, NULL, 0) == -1 )
                    {
                    printf("Error Reply() \n");
                    printf("Error : %s\n", strerror(errno));
                    return (EXIT_FAILURE);
                    }
                }
            }
        }
    }

return (EXIT_SUCCESS);
}

void alarmh()
{
long int rate = 0;

if( BLOCKSIZE <= 512 )
    {
    rate = ((counter * BLOCKSIZE) / (SECS * 1024)); 
    printf("Blocksize: %d Bytes \n", BLOCKSIZE);
    printf("Rate (small) : %d kB/s\n", rate);
    }
else
    {
    rate = ((counter / 1024) * (BLOCKSIZE / SECS)); 
    printf("Blocksize: %d Bytes \n", BLOCKSIZE);
    printf("Rate (small) : %d kB/s\n", rate);
    }

kill(npid, SIGUSR1); //  terminieren

exit(0);             //  verlassen
}

void sigh()
{
if( flag == 0 ) { flag = 1; }
else { flag = 0; }

return;
}

Correction
I become always different data rates regardless root or normal mode.

Thank You

That’s what I would expect ;) Further more using alarm and signal isn’t very precise since precision is bound by ticksize. But using a 15 second test should make the jitter insignificant.

Thank You mario

But what’s the reason for so different results
shown in “rate.jpg” ???

But what’s the reason for so different results
shown in “rate.jpg” ???

Thank you