Re: Suggestions of design (contd.)
From: Kelvin Moss (km_jr_usenet_at_yahoo.com)
Date: 02/18/05
- Next message: Kelvin Moss: "Prioritized locking"
- Previous message: Måns Rullgård: "Re: Problems building shared library with multiple sources"
- In reply to: Måns Rullgård: "Re: Suggestions of design (contd.)"
- Next in thread: moi: "Re: Suggestions of design (contd.)"
- Reply: moi: "Re: Suggestions of design (contd.)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 18 Feb 2005 07:21:30 -0800
Måns Rullgård wrote:
> "Kelvin Moss" <km_jr_usenet@yahoo.com> writes:
> What is the program doing otherwise? If it spends most of the time
> waiting on a socket or similar, you could use select() with a timeout
> to get a chance at doing other things every now and then.
Yes, a call similar to select can help me here.
Well the program is meant for SNMP statistics. So it is something like
this in short --
1. The SNMP subagent creates a shared memory region and semaphore
2. It registers a handler so that it can know the state of shared
memory every second. It needs to flush the shared memory too after it
has read it.
3. If a snmpget request comes then it needs to answer the desired
value.
I am using NetSNMP library (Linux).
So the way we wait for snmpget requests is --
while(1) {
/* if you use select(), see snmp_select_info() in snmp_api(3) */
/* Some processing */
agent_check_and_process(1); /* 0 == don't block */
}
agent_check_and_process api blocks till an snmpget is encountered or an
alarm condition occurred. I can use the latter to do some processing
from time to time.
> > I know that having statements like printf etc in signal handler is
> > disastrous since it in turn could be calling malloc etc. Is there
any
> > danger which I am overlooking when I grab semaphore and do some
> > processing in the signal handler ?
>
> If you only use functions that are explicitly mentioned as safe to
> call from a signal handler, you'll be fine. I'm not sure about the
> semaphore functions, but the safe functions are the minority out
> there.
Yes.
Thanks for all your inputs. I really appreciate them.
- Next message: Kelvin Moss: "Prioritized locking"
- Previous message: Måns Rullgård: "Re: Problems building shared library with multiple sources"
- In reply to: Måns Rullgård: "Re: Suggestions of design (contd.)"
- Next in thread: moi: "Re: Suggestions of design (contd.)"
- Reply: moi: "Re: Suggestions of design (contd.)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|