Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in threading (HP Digital)

 
anup1890
Occasional Advisor

Problem in threading (HP Digital)

Hi,
We have a mutlithreaded application into which we recently done some modifications . we are calling a function "X" from function thread "Y" and we are passing a structure from Y to X and in this X we are just doing a copy of one integer variable from the structure to a char pointer using scanaf. Whats happening is after processing some records these threads are not able to copy integer value to char*.
When we printed the integer variable its comming properly but i dont understand why then it is not able to copy it. Can any one please tell what could be the reason for this phenomenon. Do i need to declare the variables in volatile or somethingelse i need to do.

Thanks
Anup
3 REPLIES 3
GuentherF
Trusted Contributor

Re: Problem in threading (HP Digital)

"it is not able to copy it"

Haha, perfect symptom description.

/Guenther
Robert Gezelter
Honored Contributor

Re: Problem in threading (HP Digital)

Anup,

This is a very vague definition of a problem. In a multi-threaded environment, there are a large number of ways in which problems with this or similar descriptions can occur.

A careful review of the sources is in order. Having done this in the past many times, it is not possible to know if the problem is a shortcoming of the modifications, or an error in the original code that is exposed by the changes. Also note that the definitions of the C RTL routines should be checked to make sure that they are "thread safe".

- Bob Gezelter, http://www.rlgsc.com
Jeremy Begg
Trusted Contributor

Re: Problem in threading (HP Digital)

I haven't heard of the scanaf() function, and there's no mention of it in the CRTL manual. Do you mean sscanf()?

If so, it seems to me you are using the wrong routine: the input to sscanf() is a pair of strings, the output is whatever the first string represents (be it integers, floats or other strings).

In other words, I don't think you would ever use sscanf() to "copy integer value to char*". I would have thought sprintf() would be better for that.

Regards,
Jeremy Begg