Hi!

Siddharth Srivastava wrote:
> 
> while working with threads in Linux(as a part of N/W programming,hence i
> an not misusing the list i guess) i encountered a strange problem..
> '
> sscanf(....) dumps core.I an using it in a multithreaded application.Is it
> because sscanf is not MT safe??.This problem has been giving me many
> sleepless nights (and hence sleepy mornings)...i would be very grateful to
> you all if you help me in this regard.

What you are describing sound like something that can be solved by a simple
lock...

IDEA: Make a function (say safesscanf(..)

in pseudocode that looks like

safesscanf(<parameters>)
{
/*lock <- with a semaphore, or a monitor*/
sem_down(semaphore);
rvalue=sscanf(<parameters>);
sem_up(semaphore);
return(rvalue);
}

The idea of the semaphore is that one and only one sscanf call will be executed
at every moment...

Once that works call safescanff whenever you need sscanf...

You can look the details up in a textbook for "Operating Systems"...

> ...

B.
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]

Reply via email to