Programming :: Locking Mutex In A Signal Handler Function?

Feb 15, 2010

locking mutex (phtread_t type) in a signal handler function (installed by function signal()) for Linux. It seems that if the mutex has been previously locked by another thread outside the signal handler function and then the signal handler function tries to lock it, the whole process hangs.

View 5 Replies


ADVERTISEMENT

Programming :: Passing Data From Interrupt Handler Function To Tasklet Function?

May 18, 2010

I am doing some Linux kernel programming for my research project. I need to record the timestamp (by using cpuid and rdtsc) when an interrupt handler (top half) is first invoked. Due to the time critical nature of the problem itself, I have to do the timestamping inside the interrupt handler itself (the first operation when the handler is called). However, I understand that tasks that are not so time critical should be deferred to a tasklet function (bottom half) for processing because other interrupts are disabled in a (top-half) interrupt handler. I am currently out of idea on how I can pass the timestamp information that I have obtained in the interrupt handler to the corresponding tasklet function.

View 2 Replies View Related

Programming :: Possible To Connect A Signal Handler To A Variable?

Nov 1, 2010

Is it possible to connect a signal handler to a variable?So when the variable changes the signal handler is called.I have a vector containing strings which i want to parse when there are one or more available strings in the vector

View 3 Replies View Related

Debian Programming :: Serial Port Signal Handler

Jan 14, 2015

Basically I'm intending to write serial RX signal handler.Application receives defined packages of data over serial which contains header and payload. Handler should analyse incoming stream and upon detection of header (header is 6B in length) switches to receive payload of length defined in header, then after receiving full message packs it and sends to application for handling.Problem I'm facing is that at random moments in signal I receive errors that "Resource temporarily unavailable" while reading from ttyOx device and I see that sometimes I miss incoming data.Also is it possible that if while I'm handling signal one more signal arrives and it is started to be handled parallel? If it is, what are the ways to prevent it? So I would be sure that no more signals will fire on same peripheral until I will finish handling what I have on my hands now.

Serial open and init:
Code: Select allint open_port(int port_nr) {
    int fd; /* File descriptor for the port */
    switch (port_nr) {
    case 1:
        fd = open("/dev/ttyO1", O_RDWR | O_NOCTTY | O_NDELAY);
        break;
   
[code]....

View 5 Replies View Related

Programming :: Designing A Signal Handler With Sigwait In UNIX?

Jan 20, 2010

I'm new to Unix and every signal handler algorithm I've seen is more or less a copy of what I'm trying to do.[URL] designing a signal handler with sigwait in UNIX?

View 1 Replies View Related

Programming :: Function Handler Is Called One Time Only Instead 2 Times If The 2 Timers Expires At A Time

Mar 2, 2011

I am using Debian linux. I have 100 timers running. If a timer expired which will generate a signal and it was mapped to a same function handler. All the timers are mapped to one function handler. The problem is if the timer expires one at a time, the function handler called at a time. But if the 2 timers expires at a time, the function handler is called one time only instead 2 times. Is it possible to invoke the function handler as many times based on timer expirary happens simultaneoulsy?

View 14 Replies View Related

General :: Create A Signal Handler Thread To Handle SIGALRM Signals?

Jan 19, 2010

I'm trying to create a signal handler thread to handle SIGALRM signals. The main thread calls the following function before creating any other threads

Code:

pthread_t Timer::Init(long _clock_interval_musec)
{
// Set interval.
clock_interval = _clock_interval_musec;
// This is called while in a single threaded environment.

[code]....

clock_interval is 50.

Is the timer not firing? Did I not set my interval correctly? Did I not proper block the signals ensuring the that the default handler would not take care of them?

View 7 Replies View Related

Programming :: Pthread And Mutex With Short Unlock Time?

Jun 15, 2010

I am wondering if pthread could make that a single thread keeps the "mutex" all the time if the time it remains unlocked is very small.

thread1
{
while (1)
{
lock; do_task(); unlock();

[code]...

I experiment the thread2 never getting access to the mutex and never printing the nice message. I would expect that once thread2 calls "lock", it would get the mutex as soon as thread1 calls unlock() but it does not seem to be the case. If I add a sleep of some microseconds (100) in thread1 after unlocking the mutex, it solves the problem.

Does anyone know if this behaviour is normal? Is there a way to configure my mutex so that thread2 receives it when unlocked?I use

pthread_mutexattr_settype(&att, PTHREAD_MUTEX_RECURSIVE_NP);
pthread_mutex_init(&handle, &att);

to create my mutex. I am running ubuntu 9.04

View 3 Replies View Related

Programming :: Mishandling Of Mutex Leads To CPU Load 100% On Hp Ia64 Platform

Apr 7, 2010

I am working on an issue in mishandling of mutex. A process was holding onto to a valid mutex for running, within this routine, it created a local mutex variable, copied the content of the valid mutex into this local mutex variable, freed the valid mutex, then used the address of the local mutex variable as the parameter to functions pthread_mutex_unlock() and pthread_mutex_destroy(). It was observed that CPU load 100% with scheduler staying in a loop. The program was halted. I try to seek an explanation to the relation between the CPU load and mutex mishandling in this scenario. I also hope some one will share the experience how this bug might manifest into problems on other platforms.

View 3 Replies View Related

Programming :: Pthread_mutex_lock Returning EDEADLK For A Mutex Of Type PTHREAD_MUTEX_RECURSIVE

May 28, 2010

I am getting following assertion in my application:

pthread_mutex_lock.c:275: __pthread_mutex_lock: Assertion `(e) != 35 || (kind != PTHREAD_MUTEX_ERRORCHECK_NP && kind != PTHREAD_MUTEX_RECURSIVE_NP)' failed.

all my mutexes are of type PTHREAD_MUTEX_RECURSIVE and as per all the man pages/tutorials, EDEADLK error is to be returned for mutex of type PTHREAD_MUTEX_ERRORCHECK ONLY.I really should not be hitting this assertion.Would some kinda weird memory corruption be causing this? Or is there something more to it that I am not aware of.I am using linux kernel 2.6.2, glibc 2.5 on PPC.

View 8 Replies View Related

Programming :: Pthread_cond_wait - When Thread1 Invokes The Mutex Lock - No Other Threads Can Access It In Parallel

Mar 2, 2011

If multiple threads operate on a single shared resource, we can lock it using pthread_mutex_lock. Uptill that it is fine, but why again pthread_cond_wait?

int shared=0; // global
.
.
// Thread 1
pthread_mutex_lock(&mutex);
shared=1;
pthread_mutex_unlock(&mutex);

When thread1 invokes the mutex lock, no other threads can access it in parallel. So why again and what for we use, pthread_cond_wait( ).

View 2 Replies View Related

Programming :: How Can A Friend Function Access A Public Function From A Base Class

Nov 16, 2010

Code:
#include <iostream>
using namespace std;

[code]...

View 1 Replies View Related

Programming :: Panic - Killing Interrupt Handler - Not Syncing

May 10, 2010

I have written a Linux kernel module (in Linux 2.4, Red Hat 9) which does the followings: It takes srcIP, sourceport, destIP, destport and loadvalue as command line arguments. If configured load value is greater than 1, it creates different channels (i.e. No of UDP channels created equals to configured load value), assign different source port and destination port to different channels and send UDP datagram in different channels. Say for example the configured parameters are as follows srcIP=10.17.17.43 destIP= 10.17.17.44 sourceport=10000 destport= 20000 loadvalue=2.

Then it creates two UDP different channels and transmits UDP packets (in every 20 milliseconds) to destination IP address (i.e., 10.17.17.44) with source port 10000, destination port 20000 in one channel and source port 10002, destination port 20000 in another channel. When I configure to pass ?loadvalue=500? and run the module, I get the below kernel panic message in system log file (i.e., var/log/messages) 0>Kernel panic: Aiee, killing interrupt handler! In interrupt handler - not syncing. Running the same linux kernel module ,in 1000 loadvalue, I get this message, eth0: Out-of-sync dirty pointer, 49937 vs. 49954 in text console. I am unable to catch the root cause of these problems and how will I solve these?

View 1 Replies View Related

Programming :: Catching Multiple Signals In A Single Handler In C?

Apr 26, 2011

Is it possible to handle multiple signals in just one handler? I only know singal() catches one signal at a time

View 2 Replies View Related

Programming :: Resources Locking In C?

May 9, 2011

I am going to write two or more programs that will take control of the same resources on Linux. What are the common methods/functions that can do locks/synchronizations in C?

View 1 Replies View Related

Programming :: Declaring A Function In A Function - C Programming

May 24, 2010

I want to declare a function in a function, but had no success till now, see the error code below and visit the project at sourceforge

[Code]...

View 14 Replies View Related

Programming :: Totem Python Plugin Programming: Any Signal For Video Mouse Click?

Feb 9, 2011

I want that I click with the mouse on the video, it paused.I notice that there is "BaconVideoWidget" which I guess is the video rendering widget but it don't have signal named "clicked":

Code:
vd = totem_object.get_video_widget()
vd.connect("clicked", vd.hide)

[code]....

View 3 Replies View Related

Programming :: Bash Array Add Function Example Using Indirect Array Reference As Function Argument?

Jun 20, 2010

I looked on the net for such function or example and didin't find anything, thus after having made one i guess it would be legitimate to drop it to see what others thinks of it.

#!/bin/bash
addelementtoarray()
{
local arrayname=$1

[code]....

View 10 Replies View Related

Programming :: C / C++ - Shared Array Accessed Without Locking

Oct 24, 2010

If I have two threads working on the same array but on different sections of the array, can they both write and read from it without locks and not have any sort of problem? If they only use completely different parts of the array always without affecting the other part?

View 3 Replies View Related

Programming :: Can Two Threads Safely Work On A Linked List Without Locking

Nov 9, 2010

I have a linked list that two threads work on simultainiousley.The first thread is adding elements to end the linked list while the second is removing them from the front. Can this be done without a lock on the linked list head when elements are beingadded/removed?

I think this lock is causing a performance hit to my application. If there isnt any safe way without it then thats fine but just thought I would check.The first thread uses this fuction to add elements to the list. Full source here. [URL]

Code:

/* Lets add the new packet to the queue. */
pthread_mutex_lock(&workers[queuenum].queue.lock); // Grab lock on queue.
if (workers[queuenum].queue.qlen == 0){ // Check if any packets are in the queue.

[code]...

View 8 Replies View Related

Programming :: Surface Fitting Using NR Function Svdfit ( ) In C Programming?

Sep 16, 2010

fit a surface i.e. W(x,y) using svdfit() provided by "Numerical Recipes in C". svdfit() is written for curve fitting and not for surface fitting.But one can use svdfit(), as claimed by authors of NR book, to do surface fitting. On page 680 of NR book, authors have given a hint on how to use svdfit() for fitting a surface. But I have not understood it.This link may be helpful (Chapter 15 th is relevant here.):[URL]This is my problem:

Code:
I have a set of 100 numbers. I want to fit a 2-Dimensional function W(x,y) to these numbers.

[code]....

View 2 Replies View Related

Programming :: Signal Emitted With CTL+D In Bash?

Oct 22, 2010

I'm doing the shell history audit logging using syslog to gather the command history. I'm using this well publicized method using trap and logger:

declare -r REAL_LOGNAME=`/usr/bin/who am i | cut -d" " -f1`
function log2syslog {
declare command
command=`fc -ln -0`
logger -p local1.notice -t bash -i ": $REAL_LOGNAME as $LOGNAME :$command"
}
trap log2syslog DEBUG TERM

The problem is that the trap on DEBUG will catch the next to last command executed (by virtue of the "fc" command) which is not the current command executed. TERM will catch that "next to last" command on exit, thus completing the logging of each command executed during that session.

However, CTL+D doesn't seem to emit a SIGTERM signal. What signal is actually being emitted and can it be trapped? I guess another question would be whether there is a way to trap history after command line execution? Moving to Bash 4.1 isn't possible in our "supported" multi-platform environment

View 5 Replies View Related

Programming :: Signal Handling In Pthread?

Mar 12, 2011

I have created a pthread, and installed a signal handler inside that, same way as we do in main( ) function. The thread's signal handler is a separate function. Surprisingly, it is not working, that is the thread's signal handler is not able to catch signals. Here is the code:

Code: #include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <signal.h>
typedef struct data

[Code]...

View 1 Replies View Related

Programming :: [C++] Cannot Catch SIGPIPE Signal?

Mar 27, 2011

I have a Socket library, written in C++, in which the method used to send data never has the opportunity to handle an errno of SIGPIPE. Thus I thought perhaps I should setup a signal handler to receive the signal, but this too is not being called.Is there something that I am missing or doing that is completely wrong? Below is the relevant code. Note that a SIGPIPE signal is generated when the Server is unable to send data to the Client (e.g. the client has terminated).Server code:

Code:
#include <TCPServerSocket.hpp>
#include <string>

[code]...

View 1 Replies View Related

Programming :: Stop User From Invoking Own Signal?

Apr 27, 2011

I have a signal handler in my tool, which is registered and used between some particular interval (i am using timer). Now this signal handler should NOT allow any other handler to be registered or invoked after this handler is once registered. Is there any way to accomplish this?

[code]...

View 6 Replies View Related

Programming :: Use CTRL+D Signal In Bash Script?

Jan 15, 2010

I am writing a bash script where I need standard Input should be saved in a file and should be terminated by passing CTRL+D signal. Any clue how can I do that in bash script.

e.g.
Enter one line at a time
Press CTRL+D to finish

View 1 Replies View Related

Programming :: Unable To Catch The SIGTERM Signal?

Apr 25, 2011

But unable to catch the SIGTERM signal if I do shutdown, as man pages says shutdown genrates the SIGTERM and SIGKILL signals, but we cant handle the SIGKILL signal. My code is working fine if I genrate the SIGTERM signal by Kill command, and also for SIGINT signgal genrated from the CTRL+c key.

Here is my code:

/* Example of using sigaction() to setup a signal handler with 3 arguments
* including siginfo_t.
*/
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>

[Code]...

View 5 Replies View Related

Programming :: Sequencing With Raising A Signal Method?

Mar 4, 2010

I was trying to program using fork(). The objective of this code is to

1. I am activating a process A - SubSuctionMotors.
2. Process A is going to stop with either of this condition
a) Switch is activated - swret=1
b) Time allowed has expired
3. Stop the process A.

[Code]...

1. We purposely force the switch to be inactive to test the child process (timer), whether after 2 seconds the motor stop. It turns out to be successful in first few attempts. After some while, the program hang, nothing is executed anymore and the program is not exit or terminated. What can cause the program to hang?

2. We tried to stop motor by switch activation (if the switch is to be successfully activated, the time it takes will always be shorter than the timer allowed time). However, the program did not seems like noticing the switch has been activated, and it just stop the motor according to timer. Why it behave this way?

View 4 Replies View Related

Programming :: Signal Error Shown - Bad Trap?

Jun 16, 2010

#!/bin/sh
trap "echo Haha" SIGUSER1
echo "asit"
count=1
while [ $count -le 10 ]
do
echo "Loop #$count"
sleep 10
count=$[ $count + 1 ]
done
echo "This is the end"

Why this is showing following error?
trap: 3: SIGUSER1: bad trap

View 4 Replies View Related

Programming :: Temporarily Blocking Or Disconnecting A GTK+ Signal?

May 21, 2010

I'm just beginning to program with GTK+, and I'm facing this issue: I want to inhibit a signal emission inside one and only one function. I've down cut my code into the smallest example I can to show you what I want to do:The "Emitter" contains a "GtkSpinBox" and it relays the "value-changed" signal, it's header:

Code:
#ifndef EMITTER_H
#define EMITTER_H

[code]....

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved