8 | | In case of system call failure (illegal arguments), the calling task |
9 | | is killed with a ''giet_exit()''. |
10 | | |
11 | | Therefore, for all these system calls, the return value has not to be tested by the calling task. |
| 8 | In case of system call failure (illegal arguments), the calling thread |
| 9 | is killed with a ''giet_pthread_exit()''. |
| 10 | |
| 11 | Therefore, for most of these system calls, there is no return value. |
31 | | == __Task related system calls__ == |
32 | | |
33 | | === 1) unsigned int '''giet_proc_task_id'''() === |
34 | | This functions returns (from the calling task context) the task index in scheduler, identifying the task amongst all task |
35 | | running on the same processor. |
36 | | No error possible. |
37 | | |
38 | | === 2) unsigned int '''giet_global_task_id'''() === |
39 | | This functions returns (from the calling task context) the global task id, unique in the system. |
| 33 | == __Thread related system calls__ == |
| 34 | |
| 35 | The following system calls implement the POSIX Threads. The ''pthread_t'' and ''pthread_attr_t'' types |
| 36 | are defined in the [source:soft/giet_vm/giet_libs/stdio.h stdio.h] file. |
| 37 | |
| 38 | === 1) int '''giet_pthread_create'''( pthread_t* buffer , pthread_attr_t* attr , void* function , void* arg ) === |
| 39 | This functions activates one thread that will execute the C function defined by the ''function'' argument. |
| 40 | All thread activated by this system call must have been defined in the application mapping. |
| 41 | The ''attr'' argument (pthread attributes) is not supported, and should be set to NULL: The stack size must be defined in the mapping, and the pthread is activated in attached mode. In the current implementation, the ''arg'' argument (argument to be passed to ''function'') is not supported, and should be set to NULL. |
| 42 | The thread identifier stored in the ''buffer'' argument by the kernel is unique in a given space: It is actually build from the 4 following informations : [x,y,p,ltid], where x,y,p are the processor coordinates, and ltid is the thread index in the scheduler. |
| 43 | * buffer : pointer on a buffer that will contain the activated thread identifier. |
| 44 | * attr : not supported in the current implementation and must be set to NULL. |
| 45 | * function : pointer on function |
| 46 | * arg : not supported |
| 47 | Return 0 if success. |
| 48 | Return -1 if no matching thread. |
| 49 | Return -2 if attr or arg not NULL. |
| 50 | |
| 51 | === 2) void '''giet_pthread_exit'''( void* string ) === |
| 52 | This function desactivates the calling thread. |
| 53 | The 'string' argument is a (user defined) log message displayed on the kernel TTY. |
| 54 | |
| 55 | === 3) unsigned int '''giet_pthread_join'''( pthread_t trdid , void** ptr ) === |
| 56 | This blocking function can be used to detect completion of a thread activated by a giet_pthread_create(). |
| 57 | It returns only when the thread identified by the ''traded'' argument is desactivated. |
| 58 | The ''ptr'' argument is not supported, and should be set to NULL. |
| 59 | * trdid : unique thread identifier in vspace. |
| 60 | * ptr : not supported. |
| 61 | Return 0 if success. |
| 62 | Return -1 if no matching thread. |
| 63 | Return -2 if ptr not NULL |
| 64 | |