/[nova]/nova/kern/proc.h
ViewVC logotype

Diff of /nova/kern/proc.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by jrydberg, Wed Mar 27 23:21:54 2002 UTC revision 1.3 by jrydberg, Wed Apr 10 00:09:52 2002 UTC
# Line 37  Foundation, Inc., 59 Temple Place - Suit Line 37  Foundation, Inc., 59 Temple Place - Suit
37  extern ihash_t proc_hash_table;  extern ihash_t proc_hash_table;
38  extern pthread_mutex_t proc_hash_lock;  extern pthread_mutex_t proc_hash_lock;
39    
40    /* Hash table for process, indexed by PID.  
41       Hash table for process groups, indexed by group ID.  
42       Hash table for sessions, indexed by session ID.  */
43    extern ihash_t proc_pidhash;
44    extern ihash_t proc_pgrphash;
45    extern ihash_t proc_sesshash;
46    
47  /* Try to find process for request port PROC_PORT.  /* Try to find process for request port PROC_PORT.
48     If we do not find one, we return NULL. ??? panic?  */     If we do not find one, we return NULL. ??? panic?  */
49  static inline struct proc *  static inline struct proc *
# Line 68  struct ucred Line 75  struct ucred
75  /* Session structure.  Holds pointer to session leader.  */  /* Session structure.  Holds pointer to session leader.  */
76  struct session  struct session
77  {  {
78    int refcnt;    int s_refcnt;
79    struct proc *s_leader;    pid_t s_sid;
80    char s_login [20];    /* ??? MAXLOGINNAME?  */    struct pgrp *s_pgrps;
81  };  };
82    
83  /* Process group.  Uses to group one or several processes into  /* Process group.  Uses to group one or several processes into
84     one group.  Members are chained on PG_MEMBERS.  */     one group.  Members are chained on PG_MEMBERS.  */
85  struct pgrp  struct pgrp
86  {  {
87    pid_t pg_id;    pid_t pg_pgid;
88    struct proc *pg_members;    struct proc *pg_plist;
89    struct pgrp *pg_hash;    struct pgrp *pg_next, **pg_prevp;
90    struct session *pg_session;    struct session *pg_session;
91    int pg_jobc;    int pg_jobc;
92  };  };
93    
94    struct login
95    {
96      int l_refcnt;
97      char l_name[0];
98    };
99    
100    
101  /* Process.  /* Process.
102    
# Line 136  struct proc Line 149  struct proc
149    struct proc *p_sibling;    struct proc *p_sibling;
150    
151    /* Link in process group.  This points to next process in group.  */    /* Link in process group.  This points to next process in group.  */
152    struct proc *p_pglist;    struct proc *p_gnext, **p_gprevp;
153    
154    /* Current working directory.  We hold a reference to Vnode.  */    /* Current working directory.  We hold a reference to Vnode.  */
155    struct vnode *p_cwd;    struct vnode *p_cwd;
# Line 175  struct proc Line 188  struct proc
188       We olso have a condition variable that we signal on when exit.  */       We olso have a condition variable that we signal on when exit.  */
189    int p_exitstatus;    int p_exitstatus;
190    pthread_cond_t p_exitcond;    pthread_cond_t p_exitcond;
191    
192      struct login *p_login;
193      int p_loginleader;
194      struct pgrp *p_pgrp;
195  };  };
196    
197    /* Check user id for process P.  If it is equal
198       to UID, return true, otherwize zero.  */
199    int check_uid_p (struct proc *p, uid_t uid);
200    
201  /* Create a named (i.e. pre-defined pid) process.  TASK_OBJECT is the  /* Create a named (i.e. pre-defined pid) process.  TASK_OBJECT is the
202     kernel task object for the process.  THREAD_OBJECT is kernel thread     kernel task object for the process.  THREAD_OBJECT is kernel thread
203     object.  Pointer to new process is returned in PP.  */     object.  Pointer to new process is returned in PP.  */
204  extern int proc_create_named (pid_t pid, rtmk_port_t task_object,  int proc_create_named (pid_t pid, rtmk_port_t task_object,
205                                rtmk_port_t thread_object, struct proc **pp);                         rtmk_port_t thread_object, struct proc **pp);
206    
207  /* Create a new dummy process.  This process can only be used with  /* Create a new dummy process.  This process can only be used with
208     the exec syscall -- since we have no state for the process.  */     the exec syscall -- since we have no state for the process.  */
209  extern int proc_dummy (struct proc **pp);  int proc_create_startup (struct proc **pp);
210    
211  /* Execute the program pointer to by FILENAME.  */  /* Execute the program pointer to by FILENAME.  */
212  extern int proc_exec (struct proc *p, char *filename,  int proc_exec (struct proc *p, char *filename,
213                        int nargv, char **argv,                 int nargv, char **argv,
214                        int nenvp, char **envp);                 int nenvp, char **envp);
215    
216    /* Used in bootstrapping to set the pgrp of processes 0 and 1. */
217    void boot_setsid (struct proc *p);
218    
219  /* Executes the program pointed to by FILENAME.  FILENAME must be  /* Executes the program pointed to by FILENAME.  FILENAME must be
220     of a valid object format.  NARGZ is number of null-terminated     of a valid object format.  NARGZ is number of null-terminated
# Line 224  int nova_S_proc_getpid (struct proc *p, Line 248  int nova_S_proc_getpid (struct proc *p,
248  int nova_S_proc_spawn (struct proc *parent, rtmk_port_t task,  int nova_S_proc_spawn (struct proc *parent, rtmk_port_t task,
249                         rtmk_port_t thread, rtmk_port_t *child_port,                         rtmk_port_t thread, rtmk_port_t *child_port,
250                         int *pidp);                         int *pidp);
251    
252    /* Set login name for process P to NAME.
253       NAME_LEN is length of NAME string (including '\0').  */
254    int nova_S_proc_setlogin (struct proc *p, char *name,
255                              size_t name_len);
256    
257    /* Get login name for process P.  Return name in NAME.  */
258    int nova_S_proc_getlogin (struct proc *p, char *name,
259                              size_t *name_len);
260    
261    /* Getters and setters for session and process group ids.  */
262    kern_return_t nova_S_proc_setsid (struct proc *p);
263    kern_return_t nova_S_proc_getsid (struct proc *callerp, pid_t pid, pid_t *sid);
264    kern_return_t nova_S_proc_setpgrp (struct proc *callerp, pid_t pid, pid_t pgid);
265    kern_return_t nova_S_proc_getpgrp (struct proc *callerp, pid_t pid, pid_t *pgid);
266    
267    /* Return user and group IDs for process P.  */
268    int nova_S_proc_getids (struct proc *p,
269                            uid_t *uids, int *nuids,
270                            gid_t *gids, int *ngids);
271    
272  /* Exception raise function.  EXC_PORT is the proc port,  /* Exception raise function.  EXC_PORT is the proc port,
273     so we can just do a "proc_lookup" on it.  THREAD is     so we can just do a "proc_lookup" on it.  THREAD is
274     the thread that caused the exception.   */     the thread that caused the exception.   */
# Line 234  kern_return_t proc_exception_raise (rtmk Line 279  kern_return_t proc_exception_raise (rtmk
279                                      int subcode, char *state,                                      int subcode, char *state,
280                                      int state_length);                                      int state_length);
281    
282    
283    /* Make process P no longer a member of its process group.
284       Note that every process is always a member of some process group;
285       this must be followed by setting P->p_pgrp and then calling
286       join_pgrp. */
287    void leave_pgrp (struct proc *p);
288    
289    /* Cause process P to join its process group. */
290    void join_pgrp (struct proc *p);
291    
292    
293    /* Inline functions for controling pid hash table.  */
294    
295    static inline void add_pid_to_hash (struct proc *p)
296    {
297      ihash_add (proc_pidhash, p->p_pid, p, 0);
298    }
299    static inline void remove_pid_from_hash (struct proc *p)
300    {
301      ihash_remove (proc_pidhash, p->p_pid);
302    }
303    static inline struct proc *pid_find (pid_t pid)
304    {
305      return (struct proc *) ihash_find (proc_pidhash, pid);
306    }
307    
308    /* Inline functions for controling pgrp hash table.  */
309    static inline void add_pgrp_to_hash (struct pgrp *pg)
310    {
311      ihash_add (proc_pgrphash, pg->pg_pgid, pg, 0);
312    }
313    static inline void remove_pgrp_from_hash (struct pgrp *pg)
314    {
315      ihash_remove (proc_pgrphash, pg->pg_pgid);
316    }
317    static inline struct pgrp *pgrp_find (pid_t pid)
318    {
319      return (struct pgrp *) ihash_find (proc_pgrphash, pid);
320    }
321    
322    /* Inline functions for controling session hash table.  */
323    static inline void add_session_to_hash (struct session *sess)
324    {
325      ihash_add (proc_sesshash, sess->s_sid, sess, 0);
326    }
327    static inline void remove_session_from_hash (struct session *sess)
328    {
329      ihash_remove (proc_sesshash, sess->s_sid);
330    }
331    static inline struct session *session_find (pid_t pid)
332    {
333      return (struct session *) ihash_find (proc_sesshash, pid);
334    }
335    
336  #endif /* _PROC_H */  #endif /* _PROC_H */

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26