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 / 1557
1556  |  1558
Subject: 
Re: getpid?
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Thu, 14 Dec 2000 21:51:54 GMT
Viewed: 
1379 times
  
the implementation of getpid() in the kernel should not
be difficult, just return the id of currently executing
process...?

Well, get hacking! ;)

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 equal than p, excluding self.
extern void killall(priority_t p);

+extern pid_t getpid(void);
+extern pid_t getppid(void);
+
#endif // __unistd_h__
diff -u -r1.3 tm.c
--- kernel/tm.c 2000/08/01 00:14:18     1.3
+++ kernel/tm.c 2000/12/14 21:49:57
@@ -542,6 +542,15 @@
   return 0;
}

+pid_t getpid(void)
+{
+  return (pid_t)cpid;
+}
+
+pid_t getppid(void)
+{
+  return (pid_t)cpid->parent;
+}

//! kill a process
/*! \param pid must be valid process ID, or undefined behaviour will result!


Eddie C. Dost
ecd@skynet.be



Message has 1 Reply:
  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)

Message is in Reply To:
  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)

7 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

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