Re: Posix/NTPL : Is particular thread alive ? (pthread_timedjoin_np ??)
Hi Guys, To finish with this thread, my last question What is altternative to phtread_timed_join_np ? I want to wait for thread temination, but not forever. Say , I can not rewrite code that creates user threads, I can just add some management thread. Hag Sameah, Lev Gilad Ben-Yossef wrote: Lev Olshvang wrote: I am looking for generic way to ask about thread existence. You mean like calling pthread_kill() with a signal number of zero? :-) Gilad -- Gilad Ben-Yossef Chief Coffee Drinker Codefidence Ltd. The code is free, your time isn't.(TM) Web:http://codefidence.com Email: [EMAIL PROTECTED] Office: +972-8-9316883 ext. 201 Fax:+972-8-9316885 Mobile: +972-52-8260388 = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Posix/NTPL : Is particular thread alive ? (pthread_timedjoin_np ??)
Lev Olshvang wrote: Hi Guys, To finish with this thread, my last question What is altternative to phtread_timed_join_np ? I want to wait for thread temination, but not forever. If you write code for Linux only I would use pthread_timed_join_np. Yes, it's non portable. If you'd ever switch OS you will have to pay the price. But it's is the right interface. If you need portable code though, I would do a loop testing with pthread_kill() for thread exitence and then sleeping. Not elegant, but work. Gilad -- Gilad Ben-Yossef Chief Coffee Drinker Codefidence Ltd. The code is free, your time isn't.(TM) Web:http://codefidence.com Email: [EMAIL PROTECTED] Office: +972-8-9316883 ext. 201 Fax:+972-8-9316885 Mobile: +972-52-8260388
Re: Posix/NTPL : Is particular thread alive ? (pthread_timedjoin_np ??)
Gilad Ben-Yossef wrote: Lev Olshvang wrote: I am looking for generic way to ask about thread existence. You mean like calling pthread_kill() with a signal number of zero? :-) Gilad -- Gilad Ben-Yossef Chief Coffee Drinker Codefidence Ltd. The code is free, your time isn't.(TM) Web:http://codefidence.com Email: [EMAIL PROTECTED] Office: +972-8-9316883 ext. 201 Fax:+972-8-9316885 Mobile: +972-52-8260388 Gilad, thank you very much. It is exactly what I was looking for. Perhaps you could also advise me on the second item I posted recenly : "What is a proper way to make User mode device (pseudo device) ?" May be my question was not expresssed in a proper terminology ? Thanks, LEV = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Posix/NTPL : Is particular thread alive ? (pthread_timedjoin_np ??)
Lev Olshvang wrote: Gilad, thank you very much. It is exactly what I was looking for. Glad I could help. Perhaps you could also advise me on the second item I posted recenly : What is a proper way to make User mode device (pseudo device) ? May be my question was not expresssed in a proper terminology ? Simply hijack the ioctl system call using a custom shared library and LD_PRELOAD. For explanation on how to do this, complete with a code example (well, it hijacks the sleep system call, not ioctl() but you'll get the idea), see the slides that follows Having fun with the dynamic linker in the following presentation: http://codefidence.com/posts/windriver-dynamic-linker Happy hacking, Gilad -- Gilad Ben-Yossef Chief Coffee Drinker Codefidence Ltd. The code is free, your time isn't.(TM) Web:http://codefidence.com Email: [EMAIL PROTECTED] Office: +972-8-9316883 ext. 201 Fax:+972-8-9316885 Mobile: +972-52-8260388 = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Posix/NTPL : Is particular thread alive ? (pthread_timedjoin_np ??) - Solved
Just solved - evidently the timeout should be specified as absolute time -- Lev Olshvang wrote: Hi friends, I seems that i have buggy implementation of pthread_timedjoin_np. Although linux does not documented this function yet ( see http://www.kernel.org/doc/man-pages/missing_pages.html ), I suspect that on my installation this function does not work properly because it returns sometimes 0, sometimes 110 and does not set errno to ETIMEOUT. After some googling I still do not know how to get thread status. As an idea i thought about using the futex() to check memory pointed my thread handle, but I am almost sure this solution (if pthread handle indeed references memory) is dirty, ... I saw on this list people with experience in thread programming and I am hope for you help. Cheers, Lev = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED] = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Posix/NTPL : Is particular thread alive ? (pthread_timedjoin_np ??)
guy keren wrote: Lev Olshvang wrote: Hi friends, I seems that i have buggy implementation of pthread_timedjoin_np. Although linux does not documented this function yet ( see http://www.kernel.org/doc/man-pages/missing_pages.html ), I suspect that on my installation this function does not work properly because it returns sometimes 0, sometimes 110 and does not set errno to ETIMEOUT. After some googling I still do not know how to get thread status. As an idea i thought about using the futex() to check memory pointed my thread handle, but I am almost sure this solution (if pthread handle indeed references memory) is dirty, ... I saw on this list people with experience in thread programming and I am hope for you help. Cheers, Lev Hi Lev, why do you want to use this non-posix API in the first place? APIs ending with '_np' are not part of the pthreads spec - and thus are not portable and should be avoided. why can't you use the standard pthread_join API? and if you need a work-around you can use some portable mechanism, e.g. synchronizing using a condition variable, having the inner thread signal it just before terminating, and the outer thread waiting on it just before calling pthread_join? --guy Hi, I am looking for generic way to ask about thread existence. The problem is that I create thread for third party function, so I can not add to this function code to use thread signalling and cond variables. Yes, I know that _np functioins are GNU extensions to POSIX, but I did not found way to query thread aliviness. Thanks for answer. L. = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Posix/NTPL : Is particular thread alive ? (pthread_timedjoin_np ??)
Lev Olshvang wrote: I am looking for generic way to ask about thread existence. You mean like calling pthread_kill() with a signal number of zero? :-) Gilad -- Gilad Ben-Yossef Chief Coffee Drinker Codefidence Ltd. The code is free, your time isn't.(TM) Web:http://codefidence.com Email: [EMAIL PROTECTED] Office: +972-8-9316883 ext. 201 Fax:+972-8-9316885 Mobile: +972-52-8260388
Posix/NTPL : Is particular thread alive ? (pthread_timedjoin_np ??)
Hi friends, I seems that i have buggy implementation of pthread_timedjoin_np. Although linux does not documented this function yet ( see http://www.kernel.org/doc/man-pages/missing_pages.html ), I suspect that on my installation this function does not work properly because it returns sometimes 0, sometimes 110 and does not set errno to ETIMEOUT. After some googling I still do not know how to get thread status. As an idea i thought about using the futex() to check memory pointed my thread handle, but I am almost sure this solution (if pthread handle indeed references memory) is dirty, ... I saw on this list people with experience in thread programming and I am hope for you help. Cheers, Lev = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Posix/NTPL : Is particular thread alive ? (pthread_timedjoin_np ??)
Lev Olshvang wrote: Hi friends, I seems that i have buggy implementation of pthread_timedjoin_np. Although linux does not documented this function yet ( see http://www.kernel.org/doc/man-pages/missing_pages.html ), I suspect that on my installation this function does not work properly because it returns sometimes 0, sometimes 110 and does not set errno to ETIMEOUT. After some googling I still do not know how to get thread status. As an idea i thought about using the futex() to check memory pointed my thread handle, but I am almost sure this solution (if pthread handle indeed references memory) is dirty, ... I saw on this list people with experience in thread programming and I am hope for you help. Cheers, Lev Hi Lev, why do you want to use this non-posix API in the first place? APIs ending with '_np' are not part of the pthreads spec - and thus are not portable and should be avoided. why can't you use the standard pthread_join API? and if you need a work-around you can use some portable mechanism, e.g. synchronizing using a condition variable, having the inner thread signal it just before terminating, and the outer thread waiting on it just before calling pthread_join? --guy = To unsubscribe, send mail to [EMAIL PROTECTED] with the word unsubscribe in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]