* Re: [ECOS] Signal handling [not found] <000401c2233e$e2c65b30$0d22a8c0@wipro.com> @ 2002-07-04 2:51 ` Roland Caßebohm 0 siblings, 0 replies; 5+ messages in thread From: Roland Caßebohm @ 2002-07-04 2:51 UTC (permalink / raw) To: Basheer Ahmed Anwar Basha Muddebihal; +Cc: ecos-discuss [-- Attachment #1: Type: text/plain, Size: 194 bytes --] On Thursday, 4. July 2002 11:40, Basheer Ahmed Anwar Basha Muddebihal wrote: > Hi Ronald > > I want to know Which part of the file you have changed > I have put the patch as attachment. Roland [-- Attachment #2: snmptask.diff --] [-- Type: text/x-diff, Size: 2771 bytes --] Index: net/snmp/agent/current/src/snmptask.c =================================================================== RCS file: /cvs/ecos/ecos-opt/snmp/agent/current/src/snmptask.c,v retrieving revision 1.5 diff -u -5 -p -r1.5 snmptask.c --- net/snmp/agent/current/src/snmptask.c 23 May 2002 23:08:10 -0000 1.5 +++ net/snmp/agent/current/src/snmptask.c 4 Jul 2002 09:47:59 -0000 @@ -172,48 +172,79 @@ CONNECTION WITH THE USE OR PERFORMANCE O #define STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL + 102400 static char netsnmp_stack[STACK_SIZE]; -static cyg_thread netsnmp_thread_data; -static cyg_handle_t netsnmp_thread_handle; - +#ifdef CYGPKG_POSIX_MAIN_THREAD +#include <pthread.h> +static pthread_t netsnmp_thread; +#else +static cyg_thread netsnmp_thread_data; +static cyg_handle_t netsnmp_thread_handle; +#endif externC void (*snmpd_reinit_function)( void ); void (*snmpd_reinit_function)( void ) = NULL; externC void snmpd( void (*initfunc)( void ) ); +#ifdef CYGPKG_POSIX_MAIN_THREAD +static void* +snmpdloop( void *data ) +{ + while ( 1 ) + snmpd(snmpd_reinit_function); +} +#else static void -snmpdloop( void ) +snmpdloop( cyg_addrword_t data ) { while ( 1 ) snmpd(snmpd_reinit_function); } +#endif // Network initialization // This function is called during system initialization to setup the whole // networking environment. // void cyg_net_snmp_init(void) { +#ifdef CYGPKG_POSIX_MAIN_THREAD + // Create the main thread + pthread_attr_t attr; + struct sched_param schedparam; + + schedparam.sched_priority = CYGPKG_NET_THREAD_PRIORITY+1; + + pthread_attr_init( &attr ); + pthread_attr_setinheritsched( &attr, PTHREAD_EXPLICIT_SCHED ); + pthread_attr_setstackaddr( &attr, &netsnmp_stack[STACK_SIZE] ); + pthread_attr_setstacksize( &attr, sizeof(netsnmp_stack) ); + pthread_attr_setschedpolicy( &attr, SCHED_RR ); + pthread_attr_setschedparam( &attr, &schedparam ); + + pthread_create( &netsnmp_thread, &attr, snmpdloop, NULL ); + +#else // Create network background thread cyg_thread_create(CYGPKG_NET_THREAD_PRIORITY+1, // Priority, just lower than the net snmpdloop, // entry - 0, // entry parameter + 0, // entry parameter "snmpd", // Name &netsnmp_stack[0], // Stack STACK_SIZE, // Size &netsnmp_thread_handle, // Handle &netsnmp_thread_data // Thread data structure ); cyg_thread_resume(netsnmp_thread_handle); // Start it // Done +#endif } [-- Attachment #3: Type: text/plain, Size: 146 bytes --] -- Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos and search the list archive: http://sources.redhat.com/ml/ecos-discuss ^ permalink raw reply [flat|nested] 5+ messages in thread
* [ECOS] Signal handling @ 2002-07-04 1:22 Roland Caßebohm 2002-07-04 2:33 ` Roland Caßebohm 0 siblings, 1 reply; 5+ messages in thread From: Roland Caßebohm @ 2002-07-04 1:22 UTC (permalink / raw) To: ecos-discuss Hi, I send signals with pthread_kill() from the snmp agent, which is not a pthread, to other threads, which are pthreads. If I send a signal from the snmp agent to the main thread it receives it. But if I send a signal to another thread, which is created from main it doesn't take effect. But if I send the same signal from another pthread not from the snmp agent it works. Why does it not work from the snmp agent thread to another pthread than main? Thanks you, Roland -- Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos and search the list archive: http://sources.redhat.com/ml/ecos-discuss ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ECOS] Signal handling 2002-07-04 1:22 Roland Caßebohm @ 2002-07-04 2:33 ` Roland Caßebohm 2002-07-04 5:05 ` Roland Caßebohm 0 siblings, 1 reply; 5+ messages in thread From: Roland Caßebohm @ 2002-07-04 2:33 UTC (permalink / raw) To: ecos-discuss On Thursday, 4. July 2002 10:21, Roland CaÃebohm wrote: > Hi, > > I send signals with pthread_kill() from the snmp agent, which is not a > pthread, to other threads, which are pthreads. > If I send a signal from the snmp agent to the main thread it receives it. > But if I send a signal to another thread, which is created from main it > doesn't take effect. > But if I send the same signal from another pthread not from the snmp agent > it works. > > Why does it not work from the snmp agent thread to another pthread than > main? > > Thanks you, > Roland I have changed the initialisation code of the snmp agent, so that it is a pthread and now it works. -- Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos and search the list archive: http://sources.redhat.com/ml/ecos-discuss ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ECOS] Signal handling 2002-07-04 2:33 ` Roland Caßebohm @ 2002-07-04 5:05 ` Roland Caßebohm 2002-07-08 7:08 ` Roland Caßebohm 0 siblings, 1 reply; 5+ messages in thread From: Roland Caßebohm @ 2002-07-04 5:05 UTC (permalink / raw) To: ecos-discuss On Thursday, 4. July 2002 11:33, Roland CaÃebohm wrote: > On Thursday, 4. July 2002 10:21, Roland CaÃebohm wrote: > > Hi, > > > > I send signals with pthread_kill() from the snmp agent, which is not a > > pthread, to other threads, which are pthreads. > > If I send a signal from the snmp agent to the main thread it receives it. > > But if I send a signal to another thread, which is created from main it > > doesn't take effect. > > But if I send the same signal from another pthread not from the snmp > > agent it works. > > > > Why does it not work from the snmp agent thread to another pthread than > > main? > > > > Thanks you, > > Roland > > I have changed the initialisation code of the snmp agent, so that it is a > pthread and now it works. I think I have been glad to early. The first pthread which is created by main() gets the signal. But another which is created by the snmp agent pthread does not recognize the signal. -- Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos and search the list archive: http://sources.redhat.com/ml/ecos-discuss ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ECOS] Signal handling 2002-07-04 5:05 ` Roland Caßebohm @ 2002-07-08 7:08 ` Roland Caßebohm 0 siblings, 0 replies; 5+ messages in thread From: Roland Caßebohm @ 2002-07-08 7:08 UTC (permalink / raw) To: ecos-discuss On Thursday, 4. July 2002 14:05, Roland CaÃebohm wrote: > On Thursday, 4. July 2002 11:33, Roland CaÃebohm wrote: > > On Thursday, 4. July 2002 10:21, Roland CaÃebohm wrote: > > > Hi, > > > > > > I send signals with pthread_kill() from the snmp agent, which is not a > > > pthread, to other threads, which are pthreads. > > > If I send a signal from the snmp agent to the main thread it receives > > > it. But if I send a signal to another thread, which is created from > > > main it doesn't take effect. > > > But if I send the same signal from another pthread not from the snmp > > > agent it works. > > > > > > Why does it not work from the snmp agent thread to another pthread than > > > main? > > > > > > Thanks you, > > > Roland > > > > I have changed the initialisation code of the snmp agent, so that it is a > > pthread and now it works. > > I think I have been glad to early. The first pthread which is created by > main() gets the signal. But another which is created by the snmp agent > pthread does not recognize the signal. I found out now that the asr-function which calls the signal_handler is not called because asr_inhibit is still set when the scheduler tries to call the asr (asr_pending is set). The thread which should receive the signal is or better should be in sleep mode. It has called select() which has called Cyg_Condition_Var::wait_inner() which has called Cyg_Scheduler::unlock_reschedule(). If the signal was sent, the thread comes out of unlock_reschedule(). The wake reason should the be BREAK but is DONE. In pthread_kill() the thread should be released - the function cyg_sigqueue() calls thread->thread->release() to do that. But when calling Cyg_Thread::release(), the sleep reason is NONE but should be WAIT, so the wake reason will not be modified and the thread will not wake up. So why is the sleep reason not WAIT? -- Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos and search the list archive: http://sources.redhat.com/ml/ecos-discuss ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-07-08 14:08 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <000401c2233e$e2c65b30$0d22a8c0@wipro.com> 2002-07-04 2:51 ` [ECOS] Signal handling Roland Caßebohm 2002-07-04 1:22 Roland Caßebohm 2002-07-04 2:33 ` Roland Caßebohm 2002-07-04 5:05 ` Roland Caßebohm 2002-07-08 7:08 ` Roland Caßebohm
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).