If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

[RESOLVED] application crashes with "real-time signal 1"

I am working on a console application under Linux. It transmits and receives data streams via special communication hardware (developed here in house). I am recording all data in RAM buffers (the communication links are at GBit/sec speed) printing to log files any anomalies after the transmission.
I have a timer which wakes my program every 100usec do fill / read data to/from DMA buffers.
Here is the problem:
The application works, but from time to time it would crash, just saying "real-time signal 1" on the terminal. This is very annoying and often ruins my test cycles. I am new to signal programming. How do I do this correctly? Do I have to employ some kind of locking within the timer function?

Re: application crashes with "real-time signal 1"

Originally Posted by johanneshau

I am working on a console application under Linux. It transmits and receives data streams via special communication hardware (developed here in house). I am recording all data in RAM buffers (the communication links are at GBit/sec speed) printing to log files any anomalies after the transmission.

I don't see any specific synchronization, i.e. no mutexes, semaphores, etc. in your code.

I haven't done real-time programming, but are you sure you can get away with coding something in a "serial" or "single-threaded" manner like you've done, given what you say you are trying to accomplish?

I would expect a program such as this to use some sort of synchronization objects to ensure there are no race conditions, or attempting to enter functions that are not re-entrant/thread-safe, etc. For example, how do you maintain this buffer that reads data every fraction of a second? How do you tell the "reader" when the buffer is ready to be read into? What if the buffer isn't emptied out from the previous cycle, and then you say "read x bytes of data into the buffer"?

Re: application crashes with "real-time signal 1"

Thanks for the replies so far.
Unforutnately I cannot post the complete code, since it is a commercial project.
The application is not (yet) multithreaded. The only other "thread" which is running is the timer function.
It is a testsystem consisting of several PCs with custom network cards (PCIe) and a custom switch. The networking hardware is developed here in-house and is not programmed with sockets, etc. (no TCP, UDP, IP). The network is a closed configuration which is specified beforehand and configuration information is loaded into each node and switch of the network. Each node can have one or more virtual connections to other nodes in the network. The application runs on each PC (Ubuntu Linux, AMD64bit, kernel 3.2).
The application is structured like this:

Code:

- load the configuration into the hardware
- set up the hardware
- set up the DMA transfers for each virtual connection
- set up the timer and signal handlers
main loop:
- wait for the timer signal
- loop through all Rx virtual connections and receive what is available in the HW buffers and copy to static arrays
- loop through all Tx virtual connections and send test data

When you press CTRL C in the terminal the main loop is terminated (terminate variable is set to 1 in the signal handler).
After the main loop the following takes place:

Code:

- delete the timer
- scan through the received data and check for missed/wrong packets, etc.
- write data and status information to log files (one for each virtaul connection) for further inspection
this happens with simple fprintf() statements.
- free allocated buffers
- de-initialize the hardware

Since the application is not multithreaded (no threads are created/started) I do not link with pthreads library. But I do link with the "rt" library
For communication with the hardware there exists an elaborate API, which provides all necessary functions for buffer management, status information, data transfer, etc.
I am logged in and running the program as root. Do you think I should use a different signal number (SIGRTMIN+3)?

The system is a test system to prove the functionality and reliability of the network. The program code evolved from former projects and customer input. I am an experienced C programmer but do not yet have any experience with signals and these timers in Linux.

Re: [RESOLVED] application crashes with "real-time signal 1"

Thank you for the hint!
I made a stripped-down program for better testing. One problem is that it happens sporadic.
After reading more about signals and timers I restructured the code (and added the initialisation as you suggested). It apparently works now, though I am not fully convinced that it really is solved (because I cannot see the real difference to the original code), but certainly the behaviour is improved.
So I am setting this to "resolved" - thank you for your time!