I have problem with pass structure to thread function in SOLARIS.When I
pass it to created thread it always has empty values.
my structure defined as:
typedef struct momMSG{
struct mbhdr hd;
struct SCRIPTMSG MOMBuf;
}MY_SCRIPTMSG;
In my main function:
MY_SCRIPTMSG rcvVLMOMbuf;
--- fill rcvVLMOMbuf with values
if((rv = thr_create(NULL,0,ServerThread,(void *)
&rcvVLMOMbuf,THR_DETACHED, &tid)) == 0)
And in thread function:
void* ServerThread(void *arg)
{
MY_SCRIPTMSG* preceivedMSG = (MY_SCRIPTMSG*) arg;
}
The pointer preceivedMSG point on empty values.
What is the reason thanks
|
|
0
|
|
|
|
Reply
|
is_vlb50 (6)
|
2/28/2006 9:11:56 AM |
|
is_vlb50@hotmail.com wrote:
> I have problem with pass structure to thread function in SOLARIS.When I
> pass it to created thread it always has empty values.
>
> my structure defined as:
> typedef struct momMSG{
> struct mbhdr hd;
> struct SCRIPTMSG MOMBuf;
> }MY_SCRIPTMSG;
>
> In my main function:
>
> MY_SCRIPTMSG rcvVLMOMbuf;
> --- fill rcvVLMOMbuf with values
> if((rv = thr_create(NULL,0,ServerThread,(void *)
> &rcvVLMOMbuf,THR_DETACHED, &tid)) == 0)
>
> And in thread function:
> void* ServerThread(void *arg)
> {
> MY_SCRIPTMSG* preceivedMSG = (MY_SCRIPTMSG*) arg;
> }
> The pointer preceivedMSG point on empty values.
> What is the reason thanks
A likely reason may be that you pass a pointer to a structure object on
the stack. By the time your new thread starts executing the object may
well be gone and you are left with a stale pointer. To fix allocate the
structure object on the heap using malloc() and free() it in the new
thread.
|
|
0
|
|
|
|
Reply
|
Maxim
|
2/28/2006 9:49:24 AM
|
|
You mean that I need before thr_create clone my structure MY_SCRIPTMSG
to another,allocated by malloc() ?
Thanks
|
|
0
|
|
|
|
Reply
|
is_vlb50
|
2/28/2006 10:01:24 AM
|
|
In article <1141120884.024803.20560@j33g2000cwa.googlegroups.com>,
is_vlb50@hotmail.com wrote:
> You mean that I need before thr_create clone my structure MY_SCRIPTMSG
> to another,allocated by malloc() ?
> Thanks
Yes.
P.S. Please include context so your question makes sense. See
http://cfaj.freeshell.org/google/
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
|
|
0
|
|
|
|
Reply
|
Barry
|
2/28/2006 10:32:20 AM
|
|
is_vlb50@hotmail.com writes:
> if((rv = thr_create(NULL,0,ServerThread,(void *)&rcvVLMOMbuf,THR_DETACHED, &tid)) == 0)
Unless you explicitly want your software to be non-portable, there
is no justification for using Solaris threads in new code. You
should be using POSIX threads instead.
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
|
|
0
|
|
|
|
Reply
|
Paul
|
3/1/2006 5:01:23 AM
|
|
|
4 Replies
163 Views
(page loaded in 0.093 seconds)
Similiar Articles: Problem with pthreads C++ wrapper class on Linux - comp ...... using the specified // Thread Function FO and passing the specified Thread Argument ... There are two very fundamental problems with your code, both rather C++-related ... Argument must be a valid movie matrix from GETFRAME - comp.soft ...problem with mixed c and fortran code - comp.lang.fortran ... Argument must ... Thread Subject: Argument must be a valid movie matrix from GETFRAME Subject: Argument must be ... intent(out) for pointer dummy argument - comp.lang.fortran ...While there are many of the problems pointers might > be ... I'm not going to reply to this thread any more. If you don't agree with my arguments, so be it. Undefined function or method 'atan2' for input arguments of type ...... www.mathworks.com/matlabcentral/newsreader/view_thread ... Undefined function or method 'atan2' for input arguments ... Problem with the variable type of function 'isfinite ... Anyone interested in x86-64 assembly? - comp.lang.asm.x86 ...Is anyone interested in starting a thread on x86-64 ... cpuid clobbers rax ; al is hidden argument to ... 64-bit, but in 32-bit (and I suspect it's the problem ... read() error - Bad Address - comp.unix.programmerHi, I'm facing a problem with my network program. ... and it's sockaddr_in structure are passed as arguments to ... from 172.16.14.52:2067 > creating a new thread to ... Bad use of stringstream temporary? - comp.lang.c++You can find that thread, with more detail and ... member function taking the const void* as argument is ... I have set myself a homework problem: << loophole ... Java Runtime.exec() and sudo. - comp.lang.java.programmer ...... the java applet that is runningunder tomcat.The problem ... execution ofthose programs and blocks the whole thread ... the command gets passedto the shell as a single argument ... matlab r2009b starting problem - comp.soft-sys.matlab# ----- T H R E A D ----- Current thread ... 0x7537b000 C:\Windows\system32\rsaenh.dll VM Arguments ... ODBC connection problem with matlab and windows 7 - comp ... Compatibility problem between windows 7, 64 bit and matlab 2008a ...Undefined function or method 'jordan' for input arguments of type ... - Newsreader ... Thread Subject: Compatibility problem between windows 7, 64 bit and matlab 2008a Unix & Linux: thread argument problem - programming.itags.orgprogramming.itags.org: Unix & Linux question: thread argument problem, created at:Wed, 07 May 2008 10:18:00 GMT with 660 bytes, last updated: Sunday, July 15, 2012, 4 ... pass argument to the Thread - Microsoft Corporation: Software ...Sir, I have faced the same problem and got it fixed with the following solution. Solution 1: Try to use Thread pool lik Threadpool t=new ... 7/26/2012 6:14:56 PM
|