SimpleOS

LXR

Navigation



Site hébergé par : enix

The LXR Cross Referencer for SOS

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Article:1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 6.5 ] [ 7 ] [ 7.5 ] [ 8 ] [ 9 ] [ 9.5 ]

Diff markup

Differences between /sos/process.h (Article 9.5) and /sos/process.h (Article 9)


001 /* Copyright (C) 2005 David Decotigny             001 /* Copyright (C) 2005 David Decotigny
002                                                   002 
003    This program is free software; you can redi    003    This program is free software; you can redistribute it and/or
004    modify it under the terms of the GNU Genera    004    modify it under the terms of the GNU General Public License
005    as published by the Free Software Foundatio    005    as published by the Free Software Foundation; either version 2
006    of the License, or (at your option) any lat    006    of the License, or (at your option) any later version.
007                                                   007    
008    This program is distributed in the hope tha    008    This program is distributed in the hope that it will be useful,
009    but WITHOUT ANY WARRANTY; without even the     009    but WITHOUT ANY WARRANTY; without even the implied warranty of
010    MERCHANTABILITY or FITNESS FOR A PARTICULAR    010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
011    GNU General Public License for more details    011    GNU General Public License for more details.
012                                                   012    
013    You should have received a copy of the GNU     013    You should have received a copy of the GNU General Public License
014    along with this program; if not, write to t    014    along with this program; if not, write to the Free Software
015    Foundation, Inc., 59 Temple Place - Suite 3    015    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
016    USA.                                           016    USA. 
017 */                                                017 */
018 #ifndef _SOS_PROCESS_H_                           018 #ifndef _SOS_PROCESS_H_
019 #define _SOS_PROCESS_H_                           019 #define _SOS_PROCESS_H_
020                                                   020 
021 /**                                               021 /**
022  * @file process.h                                022  * @file process.h
023  *                                                023  *
024  * SOS Definition of a process and associated     024  * SOS Definition of a process and associated management API. A
025  * process is basically the collection of all     025  * process is basically the collection of all the resources requested
026  * by a user program. The threads are one of t    026  * by a user program. The threads are one of these resources, the
027  * mm_context is one other example of such res    027  * mm_context is one other example of such resources.  In SOS, a
028  * "process" is mainly a resource manager, a c    028  * "process" is mainly a resource manager, a container. It does not
029  * provide much advanced functionality apart f    029  * provide much advanced functionality apart from a reference counter.
030  *                                                030  *
031  * Only the user threads belong to a process.     031  * Only the user threads belong to a process. The kernel
032  * threads don't because the resources they ho    032  * threads don't because the resources they hold are held by the whole
033  * kernel, thus by ALL the threads (kernel AND    033  * kernel, thus by ALL the threads (kernel AND user): the notion of
034  * "process" doesn't have any meaning for them    034  * "process" doesn't have any meaning for them because they don't own
035  * any proper resource (apart from their stack    035  * any proper resource (apart from their stack).
036  */                                               036  */
037                                                   037 
038 #include <sos/errno.h>                            038 #include <sos/errno.h>
039                                                   039 
040 /**                                               040 /**
041  * The definition of an SOS process is opaque.    041  * The definition of an SOS process is opaque. @see process.c
042  */                                               042  */
043 struct sos_process;                               043 struct sos_process;
044                                                   044 
045 #include <sos/thread.h>                           045 #include <sos/thread.h>
046 #include <sos/fs.h>                               046 #include <sos/fs.h>
047                                                   047 
048                                                   048 
049 /**                                               049 /**
050  * Default size of a user stack (8 MB)            050  * Default size of a user stack (8 MB)
051  */                                               051  */
052 #define SOS_DEFAULT_USER_STACK_SIZE (8 << 20)     052 #define SOS_DEFAULT_USER_STACK_SIZE (8 << 20)
053                                                   053 
054                                                   054 
055 /**                                               055 /**
056  * Initialization of the process subsystem        056  * Initialization of the process subsystem
057  */                                               057  */
058 sos_ret_t sos_process_subsystem_setup(void);   !! 058 sos_ret_t sos_process_subsystem_setup();
059                                                   059 
060                                                   060 
061 /**                                               061 /**
062  * Initialize a new process and return a refer    062  * Initialize a new process and return a reference to it. This
063  * means that:                                    063  * means that:
064  *  - A new mm_context has been initialized       064  *  - A new mm_context has been initialized
065  *  - No threads belong to this process yet       065  *  - No threads belong to this process yet
066  *  - If do_copy_current_process is FALSE:        066  *  - If do_copy_current_process is FALSE:
067  *     - Nothing is mapped in user space          067  *     - Nothing is mapped in user space
068  *     - No other resource is used                068  *     - No other resource is used
069  *  - If do_copy_current_process is TRUE:         069  *  - If do_copy_current_process is TRUE:
070  *     - Same user mapping as in current threa    070  *     - Same user mapping as in current thread's process
071  *     - Same other resources used as for curr    071  *     - Same other resources used as for current thread's processs
072  *                                                072  *
073  * @return NULL on error (not enough memory)      073  * @return NULL on error (not enough memory)
074  */                                               074  */
075 struct sos_process *sos_process_create(const c    075 struct sos_process *sos_process_create(const char *name,
076                                        sos_boo    076                                        sos_bool_t do_copy_current_process);
077                                                   077 
078                                                   078 
079 /**                                               079 /**
080  * Signal we're using another reference to a p    080  * Signal we're using another reference to a process.
081  */                                               081  */
082 sos_ret_t sos_process_ref(struct sos_process *    082 sos_ret_t sos_process_ref(struct sos_process *proc);
083                                                   083 
084                                                   084 
085 /**                                               085 /**
086  * Release the reference to a process. If nobo    086  * Release the reference to a process. If nobody holds a reference to
087  * it and if the process does not have any thr    087  * it and if the process does not have any thread anymore, the process
088  * is destroyed.                                  088  * is destroyed.
089  *                                                089  *
090  * @return -SOS_EBUSY when the process is stil    090  * @return -SOS_EBUSY when the process is still referenced afterwards
091  */                                               091  */
092 sos_ret_t sos_process_unref(struct sos_process    092 sos_ret_t sos_process_unref(struct sos_process *proc);
093                                                   093 
094                                                   094 
095 /**                                               095 /**
096  * Return the number of threads currently regi    096  * Return the number of threads currently registered in the process
097  */                                               097  */
098 sos_count_t sos_process_get_nb_threads(const s    098 sos_count_t sos_process_get_nb_threads(const struct sos_process *proc);
099                                                   099 
100                                                   100 
101 /**                                               101 /**
102  * Retrieve the address of the MMU configurati    102  * Retrieve the address of the MMU configuration description
103  *                                                103  *
104  * @return NULL on error                          104  * @return NULL on error
105  */                                               105  */
106 struct sos_mm_context *                           106 struct sos_mm_context *
107 sos_process_get_mm_context(const struct sos_pr    107 sos_process_get_mm_context(const struct sos_process *proc);
108                                                   108 
109                                                   109 
110 /**                                               110 /**
111  * Retrieve the address space for the process     111  * Retrieve the address space for the process
112  *                                                112  *
113  * @return NULL on error                          113  * @return NULL on error
114  */                                               114  */
115 struct sos_umem_vmm_as *                          115 struct sos_umem_vmm_as *
116 sos_process_get_address_space(const struct sos    116 sos_process_get_address_space(const struct sos_process *proc);
117                                                   117 
118                                                   118 
119 /**                                               119 /**
120  * Retrieve the root FS node of the process       120  * Retrieve the root FS node of the process
121  *                                                121  *
122  * @return NULL on error                          122  * @return NULL on error
123  */                                               123  */
124 struct sos_fs_opened_file *                       124 struct sos_fs_opened_file *
125 sos_process_get_root(const struct sos_process     125 sos_process_get_root(const struct sos_process *proc);
126                                                   126 
127                                                   127 
128 /**                                               128 /**
129  * Retrieve the current working dir of the pro    129  * Retrieve the current working dir of the process
130  *                                                130  *
131  * @return NULL on error                          131  * @return NULL on error
132  */                                               132  */
133 struct sos_fs_opened_file *                       133 struct sos_fs_opened_file *
134 sos_process_get_cwd(const struct sos_process *    134 sos_process_get_cwd(const struct sos_process *proc);
135                                                   135 
136                                                   136 
137 /**                                               137 /**
138  * Retrieve the opened file structure correspo    138  * Retrieve the opened file structure corresponding to the given FD
139  *                                                139  *
140  * @return NULL on error                          140  * @return NULL on error
141  */                                               141  */
142 struct sos_fs_opened_file *                       142 struct sos_fs_opened_file *
143 sos_process_get_opened_file(const struct sos_p    143 sos_process_get_opened_file(const struct sos_process *proc,
144                             int fd);              144                             int fd);
145                                                   145 
146                                                   146 
147 /**                                               147 /**
148  * Change the root directory for the process      148  * Change the root directory for the process
149  */                                               149  */
150 sos_ret_t                                         150 sos_ret_t
151 sos_process_chroot(struct sos_process *proc,      151 sos_process_chroot(struct sos_process *proc,
152                    struct sos_fs_opened_file *    152                    struct sos_fs_opened_file * new_root,
153                    struct sos_fs_opened_file *    153                    struct sos_fs_opened_file ** old_root);
154                                                   154 
155                                                   155 
156 /**                                               156 /**
157  * Change the working directory of the process    157  * Change the working directory of the process
158  */                                               158  */
159 sos_ret_t                                         159 sos_ret_t
160 sos_process_chdir(struct sos_process *proc,       160 sos_process_chdir(struct sos_process *proc,
161                   struct sos_fs_opened_file *     161                   struct sos_fs_opened_file * new_cwd,
162                   struct sos_fs_opened_file **    162                   struct sos_fs_opened_file ** old_cwd);
163                                                   163 
164                                                   164 
165 /**                                               165 /**
166  * Allocate a new file descriptor for file        166  * Allocate a new file descriptor for file
167  *                                                167  *
168  * @return >=0 on success, <0 on error (errno)    168  * @return >=0 on success, <0 on error (errno)
169  */                                               169  */
170 sos_ret_t                                         170 sos_ret_t
171 sos_process_register_opened_file(struct sos_pr    171 sos_process_register_opened_file(struct sos_process *proc,
172                                  struct sos_fs    172                                  struct sos_fs_opened_file * of);
173                                                   173 
174                                                   174 
175 /**                                               175 /**
176  * Free the given file descriptor                 176  * Free the given file descriptor
177  *                                                177  *
178  * @return >=0 on success, <0 on error (errno)    178  * @return >=0 on success, <0 on error (errno)
179  */                                               179  */
180 sos_ret_t                                         180 sos_ret_t
181 sos_process_unregister_opened_file(struct sos_    181 sos_process_unregister_opened_file(struct sos_process *proc,
182                                    int fd);       182                                    int fd);
183                                                   183 
184                                                   184 
185 /* *******************************************    185 /* ***************************************************
186  * Restricted functions                           186  * Restricted functions
187  */                                               187  */
188                                                   188 
189                                                   189 
190 /**                                               190 /**
191  * Change the name of the process                 191  * Change the name of the process
192  */                                               192  */
193 sos_ret_t sos_process_set_name(struct sos_proc    193 sos_ret_t sos_process_set_name(struct sos_process * proc,
194                                const char * ne    194                                const char * new_name);
195                                                   195 
196                                                   196 
197 /**                                               197 /**
198  * Attach the given thread to the process         198  * Attach the given thread to the process
199  *                                                199  *
200  * @note This function is called internally by    200  * @note This function is called internally by thread.c . The thread
201  * is assumed to be in the "CREATED" state, ie    201  * is assumed to be in the "CREATED" state, ie one cannot attach a
202  * thread to some other process once it has be    202  * thread to some other process once it has been created.
203  */                                               203  */
204 sos_ret_t sos_process_register_thread(struct s    204 sos_ret_t sos_process_register_thread(struct sos_process *in_proc,
205                                       struct s    205                                       struct sos_thread *thr);
206                                                   206 
207                                                   207 
208 /**                                               208 /**
209  * Remove the given thread from the given proc    209  * Remove the given thread from the given process threads' list. When
210  * the process becomes empty (ie does not cont    210  * the process becomes empty (ie does not contain any thread anymore
211  * and is not referenced by anybody), all its     211  * and is not referenced by anybody), all its resources are released.
212  *                                                212  *
213  * @note This function is called internally by    213  * @note This function is called internally by thread.c . The thread
214  * is assumed to be in the "ZOMBIE" state.        214  * is assumed to be in the "ZOMBIE" state.
215  */                                               215  */
216 sos_ret_t sos_process_unregister_thread(struct    216 sos_ret_t sos_process_unregister_thread(struct sos_thread *thr);
217                                                   217 
218                                                   218 
219 /**                                               219 /**
220  * Replace the address space of the process by    220  * Replace the address space of the process by another one
221  *                                                221  *
222  * @note The previous address space (if any) i    222  * @note The previous address space (if any) is deleted !
223  */                                               223  */
224 sos_ret_t sos_process_set_address_space(struct    224 sos_ret_t sos_process_set_address_space(struct sos_process *proc,
225                                         struct    225                                         struct sos_umem_vmm_as *new_as);
226                                                   226 
227 #endif /* _SOS_PROCESS_H_ */                      227 #endif /* _SOS_PROCESS_H_ */
                                                      

source navigation ] diff markup ] identifier search ] general search ]