To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 1548
  getpid?
 
Hello, I am looking for a way how to obtain an identifier of a calling thread/process... I have to distinguish between different threads in the code and thus missing some equivalent to UNIX-like thr_self() / pthread_self() / getpid() any (...) (24 years ago, 13-Dec-00, to lugnet.robotics.rcx.legos)
 
  Re: getpid?
 
(...) AFAIK there aren't any built-in mechanisms. However, when a thread is launched, the launching process does get its PID as a return value from execi(). I'm thinking you could pass in a pointer to some storage in the argv, and then update that (...) (24 years ago, 14-Dec-00, to lugnet.robotics.rcx.legos)
 
  Re: getpid?
 
(...) this is not exactly what I meant. What I am looking for is how can a piece of code determine which process is currently executing it. something like: main(...) ... create 2 processes with pid1, pid2 ... these processes occasionally call (...) (24 years ago, 14-Dec-00, to lugnet.robotics.rcx.legos)
 
  Re: getpid?
 
(...) [code snipped] Ah, I understand. You could still use my method, but you'd have to pass the pid in as a parameter to the functions that need to know it, which would be ugly. (...) Well, get hacking! ;) (24 years ago, 14-Dec-00, to lugnet.robotics.rcx.legos)
 
  Re: getpid?
 
(...) The following patch will add both getpid() and getppid() to legOS: diff -u -r1.2 unistd.h --- include/unistd.h 2000/08/01 01:12:40 1.2 +++ include/unistd.h 2000/12/14 21:49:56 @@ -94,4 +94,7 @@ //! kill all processes with priority lower or (...) (24 years ago, 14-Dec-00, to lugnet.robotics.rcx.legos)
 
  Re: getpid?
 
Eddie, Would there be any problem making these inline, seeing how they're one-liners? (I'm assuming here that the H8 target implements inline) Regards, ROSCO (...) (24 years ago, 15-Dec-00, to lugnet.robotics.rcx.legos)
 
  Re: getpid?
 
(...) I wouldn't want to do so, not because the H8 does not implement inline, but because cpid is a local variable to tm.c (although it is not declared as such...). I think it's cleaner to have this user - kernel interface in real functions. Eddie (...) (24 years ago, 15-Dec-00, to lugnet.robotics.rcx.legos)

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR