View topic - timeslice question

timeslice question

Discussion about the QNX6 OS.

Postby mario » Sat Feb 07, 2009 8:38 pm

If the machine has multiple core,s just for the critical loop the priority is set at the maximum that could work.
mario
QNX Master
 
Posts: 4132
Joined: Sun Sep 01, 2002 1:04 am

Postby davidk2 » Mon Feb 09, 2009 9:52 am

Yes I thought about setting the priority high when I enter the critical section although the machine that we are using is not multi-core (it is an industrial P.C.).

I also suggested an interrupt handler but this was not entertained.

To explain this a bit further the driver that I am trying to fix this problem is a modbus communications driver. The problem is specifically when using serial communications.

Unfortunately the communications are synchronise and are timing dependent meaning we are polling the serial port (bad) to see if there is new data on the serial port.

The problem occurs when we are polling the port we get message A and between us getting and sending the message something with a higher priority uses allot of cpu thus delaying us sending the message. When this delay happens the master, or requester, actually times-out onto the message and goes onto the next message. We then get cpu time and send the response but we are actually responding to a different message which unfortunately is the same size as the last message we sent and thus it take the data from message A as the data from message B. This causes the data in the master, or requester, to change dramatically.

My problem is I cannot spend any length of time on this as this is only happening with one client. I could probably spend one/two day(s) to fully write all specs. etc implement and test the solution.

So in truth I think there is no solution to this problem (at least that I can justify) and so thank you all very much for your help.

David
davidk2
Active Member
 
Posts: 46
Joined: Mon Mar 03, 2008 4:06 pm

Postby juanplacco » Mon Feb 09, 2009 2:38 pm

something with a higher priority uses allot of cpu


Maybe, the problem is to realize what that 'something' is...
juanplacco
Senior Member
 
Posts: 318
Joined: Wed May 17, 2006 2:30 pm

Postby davidk2 » Wed Jul 28, 2010 11:23 am

Hi all,

Sorry for the necro of this thread but I am still interested in this. Are you saying that by disabling interrupts my thread will not be preempted? even if a thread with higher priority requires cpu?

What I am really looking for is an way to make a function run without being preempted.

Btw, I only use between 10-13milliseconds in my function (on a 1.7Ghz processor will be less on a faster processor), unless of course it has been preempted in which case I can see that value go up to 150milliseconds or above !

I may just raise the priority to 63 for this period. I think I may have found the offending proccess that causes the high CPU and I agree that this is the real problem here.

David
davidk2
Active Member
 
Posts: 46
Joined: Mon Mar 03, 2008 4:06 pm

Postby maschoen » Wed Jul 28, 2010 2:38 pm

davidk2 wrote:Hi all,

Sorry for the necro of this thread but I am still interested in this. Are you saying that by disabling interrupts my thread will not be preempted? even if a thread with higher priority requires cpu?



I didn't say it, but yes that is correct. In a single processor system, if you turn off interrupts, you cannot be pre-empted. Without external interrupts, processors execute code linearly. Other than a peripheral triggering a hardware interrupt, only the timer would cause a pre-emption and/or rescheduling. The only exception I can think of to this would be an internal interrupt caused by something like executing a bad instruction or a segmentation violation.


What I am really looking for is an way to make a function run without being preempted.


Btw, I only use between 10-13milliseconds in my function (on a 1.7Ghz processor will be less on a faster processor), unless of course it has been preempted in which case I can see that value go up to 150milliseconds or above !

I may just raise the priority to 63 for this period. I think I may have found the offending proccess that causes the high CPU and I agree that this is the real problem here.

David


Either turning off interrupts, or raising the priority will accomplish this. Which is best might depend on how critical the timing is. Raising the priority, you will still get interrupted, by other interrupts, or possibly by some OS process. I think in QNX 4 you can raise your priority above that of PROC but I'm not sure.

You should be very careful about either method if you are polling. If you have a hardware glitch and you are waiting for something that will never happen, you will hang your system. To prevent this, you might need to put a timeout counter in your code. This is a very old-school way of doing things.
maschoen
QNX Master
 
Posts: 2715
Joined: Wed Jun 25, 2003 5:18 pm

Postby davidk2 » Thu Jul 29, 2010 10:04 am

maschoen wrote:
davidk2 wrote:Hi all,

Sorry for the necro of this thread but I am still interested in this. Are you saying that by disabling interrupts my thread will not be preempted? even if a thread with higher priority requires cpu?



I didn't say it, but yes that is correct. In a single processor system, if you turn off interrupts, you cannot be pre-empted. Without external interrupts, processors execute code linearly. Other than a peripheral triggering a hardware interrupt, only the timer would cause a pre-emption and/or rescheduling. The only exception I can think of to this would be an internal interrupt caused by something like executing a bad instruction or a segmentation violation.


What I am really looking for is an way to make a function run without being preempted.


Btw, I only use between 10



Thanks allot for your reply. I will ponder this.

David
davidk2
Active Member
 
Posts: 46
Joined: Mon Mar 03, 2008 4:06 pm

Previous

Return to QNX6 - OS

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest