|
[ source navigation ] [ diff markup ] [ identifier search ] [ general search ] |
|||
|
001 /* Copyright (C) 2005 David Decotigny 002 003 This program is free software; you can redistribute it and/or 004 modify it under the terms of the GNU General Public License 005 as published by the Free Software Foundation; either version 2 006 of the License, or (at your option) any later version. 007 008 This program is distributed in the hope that it will be useful, 009 but WITHOUT ANY WARRANTY; without even the implied warranty of 010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 011 GNU General Public License for more details. 012 013 You should have received a copy of the GNU General Public License 014 along with this program; if not, write to the Free Software 015 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 016 USA. 017 */ 018 #ifndef _SOS_PROCESS_H_ 019 #define _SOS_PROCESS_H_ 020 021 /** 022 * @file process.h 023 * 024 * SOS Definition of a process and associated management API. A 025 * process is basically the collection of all the resources requested 026 * by a user program. The threads are one of these resources, the 027 * mm_context is one other example of such resources. In SOS, a 028 * "process" is mainly a resource manager, a container. It does not 029 * provide much advanced functionality apart from a reference counter. 030 * 031 * Only the user threads belong to a process. The kernel 032 * threads don't because the resources they hold are held by the whole 033 * kernel, thus by ALL the threads (kernel AND user): the notion of 034 * "process" doesn't have any meaning for them because they don't own 035 * any proper resource (apart from their stack). 036 */ 037 038 #include <sos/errno.h> 039 040 041 /** 042 * The definition of an SOS process is opaque. @see process.c 043 */ 044 struct sos_process; 045 046 #include <sos/thread.h> 047 048 049 /** 050 * Default size of a user stack (8 MB) 051 */ 052 #define SOS_DEFAULT_USER_STACK_SIZE (8 << 20) 053 054 055 /** 056 * Initialization of the process subsystem 057 */ 058 sos_ret_t sos_process_subsystem_setup(); 059 060 061 /** 062 * Initialize a new (empty) process and return a reference to it. This 063 * means that: 064 * - A new mm_context has been initialized 065 * - No threads belong to this process yet 066 * - Nothing is mapped in user space 067 * - No other resource is used 068 * 069 * @return NULL on error (not enough memory) 070 */ 071 struct sos_process *sos_process_create_empty(const char *name); 072 073 074 /** 075 * Signal we're using another reference to a process. 076 */ 077 sos_ret_t sos_process_ref(struct sos_process *proc); 078 079 080 /** 081 * Release the reference to a process. If nobody holds a reference to 082 * it and if the process does not have any thread anymore, the process 083 * is destroyed. 084 * 085 * @return -SOS_EBUSY when the process is still referenced afterwards 086 */ 087 sos_ret_t sos_process_unref(struct sos_process *proc); 088 089 090 /** 091 * Return the number of threads currently registered in the process 092 */ 093 sos_count_t sos_process_get_nb_threads(const struct sos_process *proc); 094 095 096 /** 097 * Retrieve the address of the MMU configuration description 098 * 099 * @return NULL on error 100 */ 101 struct sos_mm_context * 102 sos_process_get_mm_context(const struct sos_process *proc); 103 104 105 /* *************************************************** 106 * Restricted functions 107 */ 108 109 110 /** 111 * Change the name of the process 112 */ 113 sos_ret_t sos_process_set_name(struct sos_process * proc, 114 const char * new_name); 115 116 117 /** 118 * Attach the given thread to the process 119 * 120 * @note This function is called internally by thread.c . The thread 121 * is assumed to be in the "CREATED" state, ie one cannot attach a 122 * thread to some other process once it has been created. 123 */ 124 sos_ret_t sos_process_register_thread(struct sos_process *in_proc, 125 struct sos_thread *thr); 126 127 128 /** 129 * Remove the given thread from the given process threads' list. When 130 * the process becomes empty (ie does not contain any thread anymore 131 * and is not referenced by anybody), all its resources are released. 132 * 133 * @note This function is called internally by thread.c . The thread 134 * is assumed to be in the "ZOMBIE" state. 135 */ 136 sos_ret_t sos_process_unregister_thread(struct sos_thread *thr); 137 138 #endif /* _SOS_PROCESS_H_ */
[ source navigation ] | [ diff markup ] | [ identifier search ] | [ general search ] |