a Process ID

I’m porting a QNX4 app to QNX6 and has a class which was used in two
seperate threads (Now converted to pthreads) In one section of code I had
the following:

pid_t pid = qnx_name_locate(0,“my_thread”,0,NULL);
if (pid == CurrentPid() )

else



In otherwords I have something like:
If your in a thread named ‘my_thread’ do one thing, else do something
else
how would I do this in QNX6. I can’t seem to find a way to get the pid of a
specific process.

PS: the original qnx_name_attach(0,“my_thread”) has now been changed to
name_attach(NULL,“my_thread”,0);


Jeffrey B. Holtz
Software Engineering
Electro Scientific Industries, Inc.
Ph: 734-332-7054
Fax: 734-332-7077
email: holtzj@esi.com

Jeff Holtz <holtzj@esi.com> wrote:

I’m porting a QNX4 app to QNX6 and has a class which was used in two
seperate threads (Now converted to pthreads) In one section of code I had
the following:

pid_t pid = qnx_name_locate(0,“my_thread”,0,NULL);
if (pid == CurrentPid() )
Do something
else
Do something else



In otherwords I have something like:
If your in a thread named ‘my_thread’ do one thing, else do something
else
how would I do this in QNX6. I can’t seem to find a way to get the pid of a
specific process.

PS: the original qnx_name_attach(0,“my_thread”) has now been changed to
name_attach(NULL,“my_thread”,0);

Hmmm… since you’ve now converted it to threads, one assumes that you
did that with a pthread_create. One of the parameters to pthread_create()
is a thread_id that can be filled with the thread ID of the newly created
thread. If you were to use that in conjunction with pthread_self() (I think)
you could test which thread you were. Or, you can pass a parameter to
the newly created threads, effectively a flag indicating the “do this” or
“do something else” part…

Cheers,
-RK


Robert Krten, PARSE Software Devices +1 613 599 8316.
Realtime Systems Architecture, Books, Video-based and Instructor-led
Training and Consulting at www.parse.com.
Email my initials at parse dot com.

Jeff Holtz <holtzj@esi.com> wrote:

I’m porting a QNX4 app to QNX6 and has a class which was used in two
seperate threads (Now converted to pthreads) In one section of code I had
the following:

pid_t pid = qnx_name_locate(0,“my_thread”,0,NULL);
if (pid == CurrentPid() )
Do something
else
Do something else



In otherwords I have something like:
If your in a thread named ‘my_thread’ do one thing, else do something
else
how would I do this in QNX6. I can’t seem to find a way to get the pid of a
specific process.

PS: the original qnx_name_attach(0,“my_thread”) has now been changed to
name_attach(NULL,“my_thread”,0);

Look at ConnectServerInfo(), it returns you the infomation of the
server, that the fd (returned from name_open()) point to.

However, I am not sure you can name_open() yourself, cause that needs
special flag (_RESMGR_FLAG_SELF) on attach, unless of cause, the proc
did something special for you.

-xtang