Skip navigation.
Home
The QNX Community Portal

View topic - select() timeout not precise in terminal

select() timeout not precise in terminal

For discussion of realtime and/or embedded programming.

select() timeout not precise in terminal

Postby tinmar » Tue Nov 17, 2009 11:39 am

I want to read something from UDP. And i write and run the program in Momentics(XP) and it works fine. The select() timeout is precise enough(8ms).
After that, i use fs-cifs and transferd the compiled files to QNX and run it in terminal.And here comes the problem. It runs but not so correctly. The timerout is not so precise now, and is about 15,16ms.
Please help...
Another question, if i want to compile the program i wrote in Momentics with linker option(if i want to use socket API in Momentics, i have to go to preference->linker and add -lsocket), what should i type in terminal to support Socket API, qcc myprogram.c -o m ... or something else?
Thx.
tinmar
New Member
 
Posts: 2
Joined: Tue Nov 17, 2009 11:28 am

Postby Tim » Tue Nov 17, 2009 2:03 pm

Tinmar,

If you are compiling from the command line in QNX you add -lsocket the same as you do in the in the IDE.

I'm not sure why your timeout is working in Momentics + QNX target machine (you clearly can't be running in XP you have to be running on a target machine) and not when you create an image file system on the target.

My initial guess is it must be something to do with priorities (ie the IDE running at a higher priority than the program is on its own). What else do you have running on the machine in terms of your own programs/threads?

Is the timer always running at 15/16ms or only occasionally that slow?

Tim
Tim
Senior Member
 
Posts: 1388
Joined: Wed Mar 10, 2004 12:28 am

Postby tinmar » Tue Nov 17, 2009 4:10 pm

thank you, Tim.
I do know when i click run in Momentics(XP) it actually runs in QNX(target machines). :wink:
You mean i just type like this:
qcc /root/prog.c -o /root/porg -lsocket

Actually i didn't create an image(a little complicated for me) and i just want to run it without running IDE in XP. So i compiled it in XP and moved the file(x86/projectname/prog) to QNX and run it in command line.
To solve this problem, i adjust the parameter of timeout. Sometimes it is smaller than 10ms(good for me), but most of the time it turns out to be much much bigger(14,15,16ms).
tinmar
New Member
 
Posts: 2
Joined: Tue Nov 17, 2009 11:28 am

Postby Tim » Tue Nov 17, 2009 4:33 pm

Tinmar,

tinmar wrote:You mean i just type like this:
qcc /root/prog.c -o /root/porg -lsocket


Yup

tinmar wrote:So i compiled it in XP and moved the file(x86/projectname/prog) to QNX and run it in command line.
To solve this problem, i adjust the parameter of timeout. Sometimes it is smaller than 10ms(good for me), but most of the time it turns out to be much much bigger(14,15,16ms).


This sounds like a problem where some other process (yours or an O/S one) or thread (yours) is interfering with the timing. Can you post your code (I assume you are using test code to test with) and tell me what is running on your QNX machine besides the basic standard stuff (ie are you running photon, any other process you created etc).

Tim
Tim
Senior Member
 
Posts: 1388
Joined: Wed Mar 10, 2004 12:28 am

Postby maschoen » Wed Nov 18, 2009 5:04 pm

You might want to try setting a high priority "setprio()" and see if this changes things.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm


Return to Realtime and Embedded

Who is online

Users browsing this forum: No registered users and 1 guest