Gurus...Unix serial-port, time-slice and timing help 
Author Message
 Gurus...Unix serial-port, time-slice and timing help

Hi to all - apologies if I am cross-posting to the wrong group.  Linux
people tend to be very aware of Operating Systems, and C/C++ programmers
might have some clues to my problem below.

First, I am just a mechanical engineer in robotics - I never took OS and
have only a high-level understanding of the kernel. I am using GNU C++
under SunOs 5.1 on a Sparc 20.  

The problem:
The Sun is serially connected to a device (pan-tilt motor unit) that works
at 9600 baud.  My C program can write to and read from it, in ASCII chars
just fine.  The program writes chars to the device, then reads back a
3-char return prompt.  

Physcially connecting a 2-channel oscilloscope on the serial port's RX/TX
and GND revealed the following:  writing 4 chars and reading the 3
char return prompt took apx. 10 millseconds (ms).  The scope showed a 1.51
ms delay between the RX and TX signals.  10 ms makes sense since a char
with start/stop bits yields:

     7 chars * 10 bits/char / 9600 bit/s = 7.3 ms
     add the delay of 1.51 ms gives a grand total of 8.81 ms

This is close to the actual scope reading...

Enveloping the read/write statements in a gettimeofday() says
read/write takes 40 ms !!

My Comp Sci friends tell me it's because of context switching.
Sparc 20 benchmarks say that a context switch takes 0.2 msec
and my friends speculate about 2 ms/time-slice.  

Our Sparc20 is a multi-user networked machine.  But I still can't
believe that the read/write cycle takes 40 ms... more than 4 times
longer than the scope reading.  I don't have many processes running
(less than 10 I'd say).  Typically I am the only one running the machine

Any clues?  Are my friends right?  Seems like an awfully long time to me!

Very grateful,


Paul Oh                
PhD Candidate
Columbia University
Dept of Mechanical Engineering
Center for Research in Intelligent Systems
http://www.*-*-*.com/ ~paul

Tue, 25 Dec 2001 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. delays: creating time delays with time.h (unix c)

2. Digi Multi-port Serial Problem - One more time

3. Time Slices

4. about the size of time slice in windows

5. Need faster time slice for threaded MFC application

6. When relinquis the remainder of the time slice to another thread

7. How to convert local time with specific time zone to UTC time in Win32 API

8. Help using time.h to calculate running time...

9. Help!: problem with fast timing for real-time application on PC

10. Printer Port , Timing of printer port, Urgent ,LaserShow

11. Serial port to serial port copying software

12. Challenge: Virtual serial ports from real serial port


Powered by phpBB® Forum Software