Changeset 457 for trunk/kernel
- Timestamp:
- Aug 2, 2018, 11:47:13 AM (6 years ago)
- Location:
- trunk/kernel
- Files:
-
- 154 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/Makefile
r444 r457 177 177 build/syscalls/sys_thread_wakeup.o \ 178 178 build/syscalls/sys_trace.o \ 179 build/syscalls/sys_fg.o 179 build/syscalls/sys_fg.o \ 180 build/syscalls/sys_is_fg.o 180 181 181 182 VFS_OBJS = build/fs/vfs.o \ … … 228 229 kern/%.h \ 229 230 kernel_config.h \ 230 $(HAL_ARCH)/core/hal_ types.h231 $(HAL_ARCH)/core/hal_kernel_types.h 231 232 $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< 232 233 … … 237 238 devices/%.h \ 238 239 kernel_config.h \ 239 $(HAL_ARCH)/core/hal_ types.h240 $(HAL_ARCH)/core/hal_kernel_types.h 240 241 $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< 241 242 … … 245 246 mm/%.h \ 246 247 kernel_config.h \ 247 $(HAL_ARCH)/core/hal_ types.h248 $(HAL_ARCH)/core/hal_kernel_types.h 248 249 $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< 249 250 … … 253 254 libk/%.h \ 254 255 kernel_config.h \ 255 $(HAL_ARCH)/core/hal_ types.h256 $(HAL_ARCH)/core/hal_kernel_types.h 256 257 $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< 257 258 … … 261 262 syscalls/syscalls.h \ 262 263 kernel_config.h \ 263 $(HAL_ARCH)/core/hal_ types.h264 $(HAL_ARCH)/core/hal_kernel_types.h 264 265 $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< 265 266 … … 269 270 fs/%.h \ 270 271 kernel_config.h \ 271 $(HAL_ARCH)/core/hal_ types.h272 $(HAL_ARCH)/core/hal_kernel_types.h 272 273 $(CC) $(KERNEL_INCLUDE) $(CFLAGS) -c -o $@ $< 273 274 -
trunk/kernel/devices/dev_dma.c
r437 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_special.h> 26 26 #include <chdev.h> -
trunk/kernel/devices/dev_dma.h
r437 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <spinlock.h> 30 30 -
trunk/kernel/devices/dev_fbf.c
r440 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_gpt.h> 27 27 #include <thread.h> -
trunk/kernel/devices/dev_fbf.h
r188 r457 25 25 #define _DEV_FBF_H 26 26 27 #include <hal_ types.h>27 #include <hal_kernel_types.h> 28 28 29 29 /**** Forward declarations ****/ -
trunk/kernel/devices/dev_iob.c
r422 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_special.h> 27 27 #include <remote_spinlock.h> -
trunk/kernel/devices/dev_iob.h
r346 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <spinlock.h> 30 30 -
trunk/kernel/devices/dev_ioc.c
r440 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_gpt.h> 27 27 #include <hal_drivers.h> -
trunk/kernel/devices/dev_ioc.h
r437 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 30 30 /**** Forward declarations ****/ -
trunk/kernel/devices/dev_mmc.c
r440 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_special.h> 26 26 #include <hal_drivers.h> -
trunk/kernel/devices/dev_mmc.h
r440 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <spinlock.h> 30 30 -
trunk/kernel/devices/dev_nic.c
r438 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_special.h> 26 26 #include <printk.h> -
trunk/kernel/devices/dev_nic.h
r437 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 30 30 /***************************************************************************************** -
trunk/kernel/devices/dev_pic.c
r438 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_special.h> 26 26 #include <chdev.h> … … 179 179 uint32_t cycle = (uint32_t)hal_get_cycles(); 180 180 if( DEBUG_DEV_PIC < cycle ) 181 printk("\n[DBG] %s : src_core[%x,%d] / dst_core[%x,%d] / cycle %d\n",182 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, cxy, lid, cycle );181 printk("\n[DBG] %s : thread %x in process %x / tgt_core[%x,%d] / cycle %d\n", 182 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, cxy, lid, cycle ); 183 183 #endif 184 184 -
trunk/kernel/devices/dev_pic.h
r437 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 30 30 /***************************************************************************************** -
trunk/kernel/devices/dev_txt.c
r438 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_special.h> 26 26 #include <hal_remote.h> -
trunk/kernel/devices/dev_txt.h
r435 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <xlist.h> 30 30 #include <remote_spinlock.h> -
trunk/kernel/fs/devfs.c
r438 r457 23 23 */ 24 24 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_special.h> 27 27 #include <hal_uspace.h> … … 99 99 #endif 100 100 101 // creates DEVFS "dev" inode in cluster IO102 error = vfs_add_child_in_parent( LOCAL_CLUSTER->io_cxy,101 // creates DEVFS "dev" inode in cluster 0 102 error = vfs_add_child_in_parent( 0, // cxy 103 103 INODE_TYPE_DIR, 104 104 FS_TYPE_DEVFS, … … 115 115 #endif 116 116 117 // create DEVFS "external" inode in cluster IO118 error = vfs_add_child_in_parent( LOCAL_CLUSTER->io_cxy,117 // create DEVFS "external" inode in cluster 0 118 error = vfs_add_child_in_parent( 0, // cxy 119 119 INODE_TYPE_DIR, 120 120 FS_TYPE_DEVFS, -
trunk/kernel/fs/fatfs.c
r440 r457 23 23 24 24 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_special.h> 27 27 #include <printk.h> -
trunk/kernel/fs/fatfs.h
r407 r457 26 26 #define _FATFS_H_ 27 27 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <rwlock.h> 30 30 #include <vfs.h> -
trunk/kernel/fs/ramfs.c
r188 r457 24 24 25 25 26 #include <hal_ types.h>26 #include <hal_kernel_types.h> 27 27 #include <hal_special.h> 28 28 #include <printk.h> -
trunk/kernel/fs/vfs.c
r441 r457 25 25 26 26 #include <kernel_config.h> 27 #include <hal_ types.h>27 #include <hal_kernel_types.h> 28 28 #include <hal_atomic.h> 29 29 #include <hal_special.h> -
trunk/kernel/fs/vfs.h
r437 r457 27 27 28 28 #include <kernel_config.h> 29 #include <hal_ types.h>29 #include <hal_kernel_types.h> 30 30 #include <hal_atomic.h> 31 31 #include <remote_rwlock.h> -
trunk/kernel/kern/chdev.c
r450 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_special.h> 27 27 #include <hal_remote.h> … … 127 127 xptr_t server_xp; // extended pointer on server thread 128 128 core_t * core_ptr; // local pointer on core running the server thread 129 uint32_t lid;// core running the server thread local index129 uint32_t server_lid; // core running the server thread local index 130 130 xptr_t lock_xp; // extended pointer on lock protecting the chdev queue 131 uint32_t different; // non zero if server thread core != client thread core132 131 uint32_t save_sr; // for critical section 133 132 … … 154 153 155 154 // get server core local index 156 lid = hal_remote_lw( XPTR( chdev_cxy , &core_ptr->lid ) );155 server_lid = hal_remote_lw( XPTR( chdev_cxy , &core_ptr->lid ) ); 157 156 158 157 #if (DEBUG_CHDEV_CMD_RX || DEBUG_CHDEV_CMD_TX) … … 210 209 #endif 211 210 211 #if (DEBUG_CHDEV_CMD_RX & 1) 212 if( (is_rx) && (DEBUG_CHDEV_CMD_RX < rx_cycle) ) 213 printk("\n[DBG] in %s : client thread %x blocked\n", __FUNCTION__, this ); 214 #endif 215 212 216 // unblock server thread if required 213 217 if( hal_remote_lw( blocked_xp ) & THREAD_BLOCKED_IDLE ) … … 216 220 #if (DEBUG_CHDEV_CMD_TX & 1) 217 221 if( (is_rx == 0) && (DEBUG_CHDEV_CMD_TX < tx_cycle) ) 218 { 219 printk("\n[DBG] in %s : server thread %x unblocked\n", __FUNCTION__, server_ptr ); 220 chdev_queue_display( chdev_xp ); 221 } 222 printk("\n[DBG] in %s : TX server thread %x unblocked\n", __FUNCTION__, server_ptr ); 223 #endif 224 225 #if (DEBUG_CHDEV_CMD_RX & 1) 226 if( (is_rx) && (DEBUG_CHDEV_CMD_RX < rx_cycle) ) 227 printk("\n[DBG] in %s : RX server thread %x unblocked\n", __FUNCTION__, server_ptr ); 222 228 #endif 223 229 … … 227 233 #if (DEBUG_CHDEV_CMD_TX & 1) 228 234 if( (is_rx == 0) && (DEBUG_CHDEV_CMD_TX < tx_cycle) ) 229 {230 235 printk("\n[DBG] in %s : thread %x registered write request in chdev\n", __FUNCTION__, this ); 231 chdev_queue_display( chdev_xp ); 232 } 236 #endif 237 238 #if (DEBUG_CHDEV_CMD_RX & 1) 239 if( (is_rx) && (DEBUG_CHDEV_CMD_RX < rx_cycle) ) 240 printk("\n[DBG] in %s : thread %x registered read request in chdev\n", __FUNCTION__, this ); 233 241 #endif 234 242 235 243 // send IPI to core running the server thread when server != client 236 different = (lid != this->core->lid) || (local_cxy != chdev_cxy); 237 if( different ) 238 { 239 dev_pic_send_ipi( chdev_cxy , lid ); 240 244 if( (server_lid != this->core->lid) || (local_cxy != chdev_cxy) ) 245 { 246 dev_pic_send_ipi( chdev_cxy , server_lid ); 247 241 248 #if (DEBUG_CHDEV_CMD_TX & 1) 242 249 if( (is_rx == 0) && (DEBUG_CHDEV_CMD_TX < tx_cycle) ) 243 printk("\n[DBG] in %s : client thread %x sent IPI to server thread %x\n", 250 printk("\n[DBG] in %s : client thread %x sent IPI to TX server thread %x\n", 251 __FUNCTION__, this, server_ptr ); 252 #endif 253 254 #if (DEBUG_CHDEV_CMD_RX & 1) 255 if( (is_rx) && (DEBUG_CHDEV_CMD_RX < rx_cycle) ) 256 printk("\n[DBG] in %s : client thread %x sent IPI to RX server thread %x\n", 244 257 __FUNCTION__, this, server_ptr ); 245 258 #endif -
trunk/kernel/kern/chdev.h
r450 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <xlist.h> 30 30 #include <remote_spinlock.h> -
trunk/kernel/kern/cluster.c
r456 r457 123 123 124 124 #if( DEBUG_CLUSTER_INIT & 1 ) 125 uint32_tcycle = (uint32_t)hal_get_cycles();125 cycle = (uint32_t)hal_get_cycles(); 126 126 if( DEBUG_CLUSTER_INIT < cycle ) 127 127 printk("\n[DBG] %s : KHM initialized in cluster %x at cycle %d\n", … … 133 133 134 134 #if( DEBUG_CLUSTER_INIT & 1 ) 135 uint32_tcycle = (uint32_t)hal_get_cycles();135 cycle = (uint32_t)hal_get_cycles(); 136 136 if( DEBUG_CLUSTER_INIT < cycle ) 137 137 printk("\n[DBG] %s : KCM initialized in cluster %x at cycle %d\n", -
trunk/kernel/kern/cluster.h
r443 r457 28 28 29 29 #include <kernel_config.h> 30 #include <hal_ types.h>30 #include <hal_kernel_types.h> 31 31 #include <bits.h> 32 32 #include <spinlock.h> -
trunk/kernel/kern/core.c
r443 r457 24 24 25 25 #include <kernel_config.h> 26 #include <hal_ types.h>26 #include <hal_kernel_types.h> 27 27 #include <hal_special.h> 28 28 #include <errno.h> -
trunk/kernel/kern/core.h
r443 r457 27 27 28 28 #include <kernel_config.h> 29 #include <hal_ types.h>29 #include <hal_kernel_types.h> 30 30 #include <list.h> 31 31 #include <rpc.h> … … 65 65 } 66 66 core_t; 67 68 /****************************************************************************************69 * This macro returns a pointer on the calling core descriptor.70 ***************************************************************************************/71 72 #define CURRENT_CORE (CURRENT_THREAD->core)73 67 74 68 /*************************************************************************************** -
trunk/kernel/kern/do_interrupt.c
r248 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <kernel_config.h> 26 26 #include <thread.h> -
trunk/kernel/kern/do_interrupt.h
r16 r457 27 27 #define _DO_INTERRUPT_H_ 28 28 29 #include <hal_ types.h>29 #include <hal_kernel_types.h> 30 30 #include <thread.h> 31 31 -
trunk/kernel/kern/do_syscall.c
r443 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_irqmask.h> 26 26 #include <do_syscall.h> … … 102 102 sys_trace, // 47 103 103 sys_fg, // 48 104 sys_ undefined,// 49104 sys_is_fg, // 49 105 105 }; 106 106 … … 160 160 else if( index == SYS_TRACE ) return "TRACE"; // 47 161 161 else if( index == SYS_FG ) return "FG"; // 48 162 else if( index == SYS_IS_FG ) return "IS_FG"; // 49 162 163 163 164 else return "undefined"; -
trunk/kernel/kern/do_syscall.h
r408 r457 27 27 #define _D0_SYSCALL_H_ 28 28 29 #include <hal_ types.h>29 #include <hal_kernel_types.h> 30 30 #include <thread.h> 31 31 -
trunk/kernel/kern/dqdt.c
r438 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_special.h> 27 27 #include <hal_atomic.h> -
trunk/kernel/kern/dqdt.h
r438 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <hal_atomic.h> 30 30 -
trunk/kernel/kern/kernel_init.c
r443 r457 25 25 #include <kernel_config.h> 26 26 #include <errno.h> 27 #include <hal_ types.h>27 #include <hal_kernel_types.h> 28 28 #include <hal_special.h> 29 29 #include <hal_context.h> … … 186 186 " /_/ \\_\\ |______| |_| |_| \\_____/ |______/ |_| |_| |_| \\_\\ |_| |_| \n" 187 187 "\n\n\t\t Advanced Locality Management Operating System / Multi Kernel Hybrid\n" 188 "\n\n\t\t Version 0.0 / %d cluster(s) / %d core(s) per cluster / cycle %d\n\n",189 nclusters , ncores , hal_time_stamp());188 "\n\n\t\t %s / %d cluster(s) / %d core(s) per cluster\n\n", 189 CONFIG_ALMOS_VERSION , nclusters , ncores ); 190 190 } 191 191 … … 761 761 reg_t status; // running core status register 762 762 763 cxy_t io_cxy = info->io_cxy;764 765 assert( (io_cxy == ((info->x_size - 1)<<(info->y_width)) + (info->y_size - 1)) ,766 __FUNCTION__ , "illegal IO cluter identifier\n" );767 768 763 ///////////////////////////////////////////////////////////////////////////////// 769 764 // STEP 0 : Each core get its core identifier from boot_info, and makes … … 796 791 thread->remote_locks = 0; 797 792 798 // CP0 in I/O clusterinitialises TXT0 chdev descriptor799 if( (core_lid == 0) && (core_cxy == io_cxy) ) txt0_device_init( info );800 801 ///////////////////////////////////////////////////////////////////////////////// 802 if( core_lid == 0 ) remote_barrier( XPTR( io_cxy, &global_barrier ),793 // CP0 in cluster 0 initialises TXT0 chdev descriptor 794 if( (core_lid == 0) && (core_cxy == 0) ) txt0_device_init( info ); 795 796 ///////////////////////////////////////////////////////////////////////////////// 797 if( core_lid == 0 ) remote_barrier( XPTR( 0 , &global_barrier ), 803 798 (info->x_size * info->y_size) ); 804 799 barrier_wait( &local_barrier , info->cores_nr ); … … 838 833 839 834 ///////////////////////////////////////////////////////////////////////////////// 840 if( core_lid == 0 ) remote_barrier( XPTR( io_cxy, &global_barrier ),835 if( core_lid == 0 ) remote_barrier( XPTR( 0 , &global_barrier ), 841 836 (info->x_size * info->y_size) ); 842 837 barrier_wait( &local_barrier , info->cores_nr ); … … 865 860 866 861 //////////////////////////////////////////////////////////////////////////////// 867 if( core_lid == 0 ) remote_barrier( XPTR( io_cxy, &global_barrier ),862 if( core_lid == 0 ) remote_barrier( XPTR( 0 , &global_barrier ), 868 863 (info->x_size * info->y_size) ); 869 864 barrier_wait( &local_barrier , info->cores_nr ); … … 898 893 899 894 ///////////////////////////////////////////////////////////////////////////////// 900 if( core_lid == 0 ) remote_barrier( XPTR( io_cxy, &global_barrier ),895 if( core_lid == 0 ) remote_barrier( XPTR( 0 , &global_barrier ), 901 896 (info->x_size * info->y_size) ); 902 897 barrier_wait( &local_barrier , info->cores_nr ); … … 926 921 927 922 // all cores initialize the idle thread descriptor 928 error = thread_idle_init( thread, 929 THREAD_IDLE, 930 &thread_idle_func, 931 NULL, 932 core_lid ); 933 if( error ) 934 { 935 assert( false , __FUNCTION__ , 936 "core[%x][%d] cannot initialize idle thread", local_cxy , core_lid ); 937 } 923 thread_idle_init( thread, 924 THREAD_IDLE, 925 &thread_idle_func, 926 NULL, 927 core_lid ); 938 928 939 929 // all cores unblock idle thread, and register it in scheduler … … 1008 998 1009 999 ///////////////////////////////////////////////////////////////////////////////// 1010 if( core_lid == 0 ) remote_barrier( XPTR( io_cxy, &global_barrier ),1000 if( core_lid == 0 ) remote_barrier( XPTR( 0 , &global_barrier ), 1011 1001 (info->x_size * info->y_size) ); 1012 1002 barrier_wait( &local_barrier , info->cores_nr ); … … 1069 1059 1070 1060 ///////////////////////////////////////////////////////////////////////////////// 1071 if( core_lid == 0 ) remote_barrier( XPTR( io_cxy, &global_barrier ),1061 if( core_lid == 0 ) remote_barrier( XPTR( 0 , &global_barrier ), 1072 1062 (info->x_size * info->y_size) ); 1073 1063 barrier_wait( &local_barrier , info->cores_nr ); … … 1076 1066 #if DEBUG_KERNEL_INIT 1077 1067 if( (core_lid == 0) & (local_cxy == 0) ) 1078 printk("\n[DBG] %s : exit barrier 5 : VFS_root = %l in cluster %x/ cycle %d\n",1079 __FUNCTION__, vfs_root_inode_xp , io_cxy ,(uint32_t)hal_get_cycles());1068 printk("\n[DBG] %s : exit barrier 5 : VFS_root = %l in cluster 0 / cycle %d\n", 1069 __FUNCTION__, vfs_root_inode_xp , (uint32_t)hal_get_cycles()); 1080 1070 #endif 1081 1071 … … 1086 1076 ///////////////////////////////////////////////////////////////////////////////// 1087 1077 1088 if( (core_lid == 0) && (local_cxy == io_cxy) )1078 if( (core_lid == 0) && (local_cxy == 0) ) 1089 1079 { 1090 1080 // create "dev" and "external" directories. … … 1104 1094 1105 1095 ///////////////////////////////////////////////////////////////////////////////// 1106 if( core_lid == 0 ) remote_barrier( XPTR( io_cxy, &global_barrier ),1096 if( core_lid == 0 ) remote_barrier( XPTR( 0 , &global_barrier ), 1107 1097 (info->x_size * info->y_size) ); 1108 1098 barrier_wait( &local_barrier , info->cores_nr ); … … 1111 1101 #if DEBUG_KERNEL_INIT 1112 1102 if( (core_lid == 0) & (local_cxy == 0) ) 1113 printk("\n[DBG] %s : exit barrier 6 : dev_root = %l in cluster %x/ cycle %d\n",1114 __FUNCTION__, devfs_dev_inode_xp , io_cxy ,(uint32_t)hal_get_cycles() );1103 printk("\n[DBG] %s : exit barrier 6 : dev_root = %l in cluster 0 / cycle %d\n", 1104 __FUNCTION__, devfs_dev_inode_xp , (uint32_t)hal_get_cycles() ); 1115 1105 #endif 1116 1106 … … 1125 1115 if( core_lid == 0 ) 1126 1116 { 1127 // get extended pointer on "extend" field of VFS context for DEVFS in cluster IO1128 xptr_t extend_xp = XPTR( io_cxy, &fs_context[FS_TYPE_DEVFS].extend );1129 1130 // get pointer on DEVFS context in cluster IO1117 // get extended pointer on "extend" field of VFS context for DEVFS in cluster 0 1118 xptr_t extend_xp = XPTR( 0 , &fs_context[FS_TYPE_DEVFS].extend ); 1119 1120 // get pointer on DEVFS context in cluster 0 1131 1121 devfs_ctx_t * devfs_ctx = hal_remote_lpt( extend_xp ); 1132 1122 1133 devfs_dev_inode_xp = hal_remote_lwd( XPTR( io_cxy , 1134 &devfs_ctx->dev_inode_xp ) ); 1135 devfs_external_inode_xp = hal_remote_lwd( XPTR( io_cxy , 1136 &devfs_ctx->external_inode_xp ) ); 1123 devfs_dev_inode_xp = hal_remote_lwd( XPTR( 0 , &devfs_ctx->dev_inode_xp ) ); 1124 devfs_external_inode_xp = hal_remote_lwd( XPTR( 0 , &devfs_ctx->external_inode_xp ) ); 1137 1125 1138 1126 // populate DEVFS in all clusters … … 1143 1131 1144 1132 ///////////////////////////////////////////////////////////////////////////////// 1145 if( core_lid == 0 ) remote_barrier( XPTR( io_cxy, &global_barrier ),1133 if( core_lid == 0 ) remote_barrier( XPTR( 0 , &global_barrier ), 1146 1134 (info->x_size * info->y_size) ); 1147 1135 barrier_wait( &local_barrier , info->cores_nr ); … … 1158 1146 ///////////////////////////////////////////////////////////////////////////////// 1159 1147 1160 if( (core_lid == 1148 if( (core_lid == 0) && (local_cxy == 0) ) 1161 1149 { 1162 1150 … … 1169 1157 1170 1158 ///////////////////////////////////////////////////////////////////////////////// 1171 if( core_lid == 0 ) remote_barrier( XPTR( io_cxy, &global_barrier ),1159 if( core_lid == 0 ) remote_barrier( XPTR( 0 , &global_barrier ), 1172 1160 (info->x_size * info->y_size) ); 1173 1161 barrier_wait( &local_barrier , info->cores_nr ); … … 1189 1177 ///////////////////////////////////////////////////////////////////////////////// 1190 1178 1191 if( (core_lid == 0) && (local_cxy == io_cxy) )1179 if( (core_lid == 0) && (local_cxy == 0) ) 1192 1180 { 1193 1181 print_banner( (info->x_size * info->y_size) , info->cores_nr ); -
trunk/kernel/kern/printk.c
r446 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_irqmask.h> 26 26 #include <hal_special.h> -
trunk/kernel/kern/printk.h
r437 r457 41 41 #define _PRINTK_H 42 42 43 #include <hal_ types.h>43 #include <hal_kernel_types.h> 44 44 #include <stdarg.h> 45 45 -
trunk/kernel/kern/process.c
r450 r457 25 25 26 26 #include <kernel_config.h> 27 #include <hal_ types.h>27 #include <hal_kernel_types.h> 28 28 #include <hal_remote.h> 29 29 #include <hal_uspace.h> … … 89 89 void process_reference_init( process_t * process, 90 90 pid_t pid, 91 xptr_t parent_xp, 92 xptr_t model_xp ) 91 xptr_t parent_xp ) 93 92 { 94 93 cxy_t parent_cxy; 95 94 process_t * parent_ptr; 96 cxy_t model_cxy;97 process_t * model_ptr;98 95 xptr_t stdin_xp; 99 96 xptr_t stdout_xp; … … 110 107 chdev_t * chdev_ptr; 111 108 cxy_t chdev_cxy; 112 pid_t model_pid;113 109 pid_t parent_pid; 114 115 // get model process cluster and local pointer116 model_cxy = GET_CXY( model_xp );117 model_ptr = GET_PTR( model_xp );118 110 119 111 // get parent process cluster and local pointer … … 121 113 parent_ptr = GET_PTR( parent_xp ); 122 114 123 // get model_pid andparent_pid115 // get parent_pid 124 116 parent_pid = hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid ) ); 125 model_pid = hal_remote_lw( XPTR( model_cxy , &model_ptr->pid ) );126 117 127 118 #if DEBUG_PROCESS_REFERENCE_INIT 128 119 uint32_t cycle = (uint32_t)hal_get_cycles(); 129 120 if( DEBUG_PROCESS_REFERENCE_INIT ) 130 printk("\n[DBG] %s : thread %x enter / pid = %x / ppid = %x / model_pid =%x / cycle %d\n",131 __FUNCTION__ , CURRENT_THREAD , pid , parent_pid , model_pid , cycle );121 printk("\n[DBG] %s : thread %x in process %x enter to initalialize process %x / cycle %d\n", 122 __FUNCTION__, CURRENT_THREAD->trdid, parent_pid , pid , cycle ); 132 123 #endif 133 124 … … 146 137 cycle = (uint32_t)hal_get_cycles(); 147 138 if( DEBUG_PROCESS_REFERENCE_INIT ) 148 printk("\n[DBG] %s : thread %x / vmm empty for process %x / cycle %d\n",149 __FUNCTION__ , CURRENT_THREAD ,pid , cycle );139 printk("\n[DBG] %s : thread %x in process %x / vmm empty for process %x / cycle %d\n", 140 __FUNCTION__, CURRENT_THREAD->trdid, parent_pid , cycle ); 150 141 #endif 151 142 … … 154 145 155 146 // define the stdin/stdout/stderr pseudo files <=> select a TXT terminal. 156 // - if INIT (pid == 1) => link to kernel TXT[0] 157 // - if KSH[i] (model_pid == 1) => allocate a free TXT[i] 158 // - if USER process => same terminal as model 159 160 if( (pid == 1) || (model_pid == 1)) // INIT or KSH process 161 { 162 if (pid == 1 ) txt_id = 0; // INIT 163 else txt_id = process_txt_alloc(); // KSH[i] 164 165 // attach process to TXT[txt_id] 147 if( (pid == 1) || (parent_pid == 1)) // INIT or KSH process 148 { 149 // allocate a TXT channel 150 if( pid == 1 ) txt_id = 0; // INIT 151 else txt_id = process_txt_alloc(); // KSH 152 153 // attach process to TXT 166 154 process_txt_attach( process , txt_id ); 155 156 #if (DEBUG_PROCESS_REFERENCE_INIT & 1) 157 cycle = (uint32_t)hal_get_cycles(); 158 if( DEBUG_PROCESS_REFERENCE_INIT ) 159 printk("\n[DBG] %s : thread %x in process %x / process %x attached to TXT%d / cycle %d\n", 160 __FUNCTION__, CURRENT_THREAD->trdid, parent_pid, pid, txt_id, cycle ); 161 #endif 162 163 167 164 168 165 // build path to TXT_RX[i] and TXT_TX[i] chdevs … … 184 181 cycle = (uint32_t)hal_get_cycles(); 185 182 if( DEBUG_PROCESS_REFERENCE_INIT ) 186 printk("\n[DBG] %s : thread %x / stdin open for process %x / cycle %d\n",187 __FUNCTION__ , CURRENT_THREAD , pid, cycle );183 printk("\n[DBG] %s : thread %x in process %x / stdin open for process %x / cycle %d\n", 184 __FUNCTION__, CURRENT_THREAD->trdid, parent_pid, pid, cycle ); 188 185 #endif 189 186 … … 202 199 cycle = (uint32_t)hal_get_cycles(); 203 200 if( DEBUG_PROCESS_REFERENCE_INIT ) 204 printk("\n[DBG] %s : thread %x / stdout open for process %x / cycle %d\n",205 __FUNCTION__ , CURRENT_THREAD , pid, cycle );201 printk("\n[DBG] %s : thread %x in process %x / stdout open for process %x / cycle %d\n", 202 __FUNCTION__, CURRENT_THREAD->trdid, parent_pid, pid, cycle ); 206 203 #endif 207 204 … … 220 217 cycle = (uint32_t)hal_get_cycles(); 221 218 if( DEBUG_PROCESS_REFERENCE_INIT ) 222 printk("\n[DBG] %s : thread %x / stderr open for process %x / cycle %d\n",223 __FUNCTION__ , CURRENT_THREAD , pid, cycle );219 printk("\n[DBG] %s : thread %x in process %x / stderr open for process %x / cycle %d\n", 220 __FUNCTION__, CURRENT_THREAD->trdid, parent_pid, pid, cycle ); 224 221 #endif 225 222 … … 227 224 else // normal user process 228 225 { 229 // get extended pointer on stdin pseudo file in modelprocess230 file_xp = (xptr_t)hal_remote_lwd( XPTR( model_cxy , &model_ptr->fd_array.array[0] ) );231 232 // get extended pointer on modelprocess TXT chdev226 // get extended pointer on stdin pseudo file in parent process 227 file_xp = (xptr_t)hal_remote_lwd( XPTR( parent_cxy , &parent_ptr->fd_array.array[0] ) ); 228 229 // get extended pointer on parent process TXT chdev 233 230 chdev_xp = chdev_from_file( file_xp ); 234 231 … … 243 240 process_txt_attach( process , txt_id ); 244 241 245 // copy all open files from modelprocess fd_array to this process242 // copy all open files from parent process fd_array to this process 246 243 process_fd_remote_copy( XPTR( local_cxy , &process->fd_array ), 247 XPTR( model_cxy , &model_ptr->fd_array ) );244 XPTR( parent_cxy , &parent_ptr->fd_array ) ); 248 245 } 249 246 250 247 // initialize specific inodes root and cwd 251 process->vfs_root_xp = (xptr_t)hal_remote_lwd( XPTR( model_cxy,252 & model_ptr->vfs_root_xp ) );253 process->vfs_cwd_xp = (xptr_t)hal_remote_lwd( XPTR( model_cxy,254 & model_ptr->vfs_cwd_xp ) );248 process->vfs_root_xp = (xptr_t)hal_remote_lwd( XPTR( parent_cxy, 249 &parent_ptr->vfs_root_xp ) ); 250 process->vfs_cwd_xp = (xptr_t)hal_remote_lwd( XPTR( parent_cxy, 251 &parent_ptr->vfs_cwd_xp ) ); 255 252 vfs_inode_remote_up( process->vfs_root_xp ); 256 253 vfs_inode_remote_up( process->vfs_cwd_xp ); … … 469 466 //////////////////////////////////////// 470 467 void process_sigaction( pid_t pid, 471 uint32_t action_type )468 uint32_t type ) 472 469 { 473 470 cxy_t owner_cxy; // owner cluster identifier … … 479 476 xptr_t process_xp; // extended pointer on process copy 480 477 cxy_t process_cxy; // process copy cluster identifier 478 process_t * process_ptr; // local pointer on process copy 481 479 reg_t save_sr; // for critical section 482 480 rpc_desc_t rpc; // shared RPC descriptor 483 484 thread_t * client = CURRENT_THREAD; 481 thread_t * client; // pointer on client thread 482 xptr_t client_xp; // extended pointer on client thread 483 process_t * local; // pointer on process copy in local cluster 484 uint32_t remote_nr; // number of remote process copies 485 486 client = CURRENT_THREAD; 487 client_xp = XPTR( local_cxy , client ); 488 local = NULL; 489 remote_nr = 0; 485 490 486 491 #if DEBUG_PROCESS_SIGACTION 487 492 uint32_t cycle = (uint32_t)hal_get_cycles(); 488 493 if( DEBUG_PROCESS_SIGACTION < cycle ) 489 printk("\n[DBG] %s : thread %x enter to %s process %x / cycle %d\n", 490 __FUNCTION__ , client, process_action_str( action_type ) , pid , cycle ); 494 printk("\n[DBG] %s : thread %x in process %x enter to %s process %x / cycle %d\n", 495 __FUNCTION__ , client->trdid, client->process->pid, 496 process_action_str( type ) , pid , cycle ); 491 497 #endif 492 498 … … 503 509 504 510 // check action type 505 assert( (( action_type == DELETE_ALL_THREADS ) ||506 ( action_type == BLOCK_ALL_THREADS ) ||507 ( action_type == UNBLOCK_ALL_THREADS )), __FUNCTION__ , "illegal action type" );511 assert( ((type == DELETE_ALL_THREADS ) || 512 (type == BLOCK_ALL_THREADS ) || 513 (type == UNBLOCK_ALL_THREADS )), __FUNCTION__ , "illegal action type" ); 508 514 509 // allocate a - shared - RPC descriptor in client thread stack 510 // it can be shared because all parallel, non-blocking, server threads 511 // use the same input arguments, and use the shared RPC response field 512 513 // the client thread makes the following sequence: 514 // 1. mask interrupts 515 // 2. block itself 516 // 3. send RPC requests to all copies 517 // 4. unmask interrupts 518 // 5. deschedule 515 516 // The client thread send parallel RPCs to all remote clusters containing 517 // target process copies, wait all responses, and then handles directly the 518 // threads in local cluster, when required. 519 // The client thread allocates a - shared - RPC descriptor in the stack, 520 // because all parallel, non-blocking, server threads use the same input 521 // arguments, and use the shared RPC response field 519 522 520 523 // mask IRQs 521 524 hal_disable_irq( &save_sr); 522 525 523 // client register blocking condition foritself524 thread_block( XPTR( local_cxy , client ), THREAD_BLOCKED_RPC );526 // client thread blocks itself 527 thread_block( client_xp , THREAD_BLOCKED_RPC ); 525 528 526 529 // take the lock protecting the copies … … 533 536 rpc.thread = client; 534 537 rpc.lid = client->core->lid; 535 rpc.args[0] = action_type;538 rpc.args[0] = type; 536 539 rpc.args[1] = pid; 537 540 538 // send RPCs to all clusters containing process copiess 541 // scan list of process copies 542 // to send RPCs to remote copies 539 543 XLIST_FOREACH( root_xp , iter_xp ) 540 544 { 541 // atomically increment responses counter 542 hal_atomic_add( (void *)&rpc.responses , 1 ); 543 545 // get extended pointers and cluster on process 544 546 process_xp = XLIST_ELEMENT( iter_xp , process_t , copies_list ); 545 547 process_cxy = GET_CXY( process_xp ); 548 process_ptr = GET_PTR( process_xp ); 549 550 if( process_cxy == local_cxy ) // process is local 551 { 552 local = process_ptr; 553 } 554 else // process is remote 555 { 556 // update number of remote process copies 557 remote_nr++; 558 559 // atomically increment responses counter 560 hal_atomic_add( (void *)&rpc.responses , 1 ); 546 561 547 562 #if DEBUG_PROCESS_SIGACTION 548 563 if( DEBUG_PROCESS_SIGACTION < cycle ) 549 printk("\n[DBG] %s : send RPC to %s process %x in cluster %x\n", 550 __FUNCTION__ , process_action_str( action_type ) , pid , process_cxy ); 551 #endif 552 // call RPC in target cluster 553 rpc_process_sigaction_client( process_cxy , &rpc ); 554 } 555 564 printk("\n[DBG] %s : thread %x in process %x handles remote process %x in cluster %x\n", 565 __FUNCTION__, client->trdid, client->process->pid, pid , process_cxy ); 566 #endif 567 // call RPC in target cluster 568 rpc_process_sigaction_client( process_cxy , &rpc ); 569 } 570 } // end list of copies 571 556 572 // release the lock protecting process copies 557 573 remote_spinlock_unlock( lock_xp ); … … 560 576 hal_restore_irq( save_sr); 561 577 562 // client thread deschedule : will be unblocked by the last RPC server thread 563 sched_yield("blocked on rpc_process_sigaction"); 578 // - if there is remote process copies, the client thread deschedules, 579 // (it will be unblocked by the last RPC server thread). 580 // - if there is no remote copies, the client thread unblock itself. 581 if( remote_nr ) 582 { 583 sched_yield("blocked on rpc_process_sigaction"); 584 } 585 else 586 { 587 thread_unblock( client_xp , THREAD_BLOCKED_RPC ); 588 } 589 590 // handle the local process copy if required 591 if( local != NULL ) 592 { 593 594 #if DEBUG_PROCESS_SIGACTION 595 if( DEBUG_PROCESS_SIGACTION < cycle ) 596 printk("\n[DBG] %s : thread %x in process %x handles local process %x in cluster %x\n", 597 __FUNCTION__, client->trdid, client->process->pid, pid , local_cxy ); 598 #endif 599 if (type == DELETE_ALL_THREADS ) process_delete_threads ( local , client_xp ); 600 else if(type == BLOCK_ALL_THREADS ) process_block_threads ( local , client_xp ); 601 else if(type == UNBLOCK_ALL_THREADS ) process_unblock_threads( local ); 602 } 564 603 565 604 #if DEBUG_PROCESS_SIGACTION 566 605 cycle = (uint32_t)hal_get_cycles(); 567 606 if( DEBUG_PROCESS_SIGACTION < cycle ) 568 printk("\n[DBG] %s : thread %x exit after %s process %x in cluster %x / cycle %d\n", 569 __FUNCTION__ , client, process_action_str( action_type ) , pid , local_cxy , cycle ); 607 printk("\n[DBG] %s : thread %x in process %x exit after %s process %x / cycle %d\n", 608 __FUNCTION__, client->trdid, client->process->pid, 609 process_action_str( type ), pid, cycle ); 570 610 #endif 571 611 … … 1100 1140 uint32_t cycle = (uint32_t)hal_get_cycles(); 1101 1141 if( DEBUG_PROCESS_MAKE_FORK < cycle ) 1102 printk("\n[DBG] %s : thread %x enter for process %x/ cluster %x / cycle %d\n",1103 __FUNCTION__, CURRENT_THREAD , parent_pid, local_cxy, cycle );1142 printk("\n[DBG] %s : thread %x in process %x enter / cluster %x / cycle %d\n", 1143 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, local_cxy, cycle ); 1104 1144 #endif 1105 1145 … … 1123 1163 } 1124 1164 1165 #if DEBUG_PROCESS_MAKE_FORK 1166 cycle = (uint32_t)hal_get_cycles(); 1167 if( DEBUG_PROCESS_MAKE_FORK < cycle ) 1168 printk("\n[DBG] %s : thread %x in process %x allocated process %x / cycle %d\n", 1169 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, new_pid, cycle ); 1170 #endif 1171 1125 1172 // initializes child process descriptor from parent process descriptor 1126 1173 process_reference_init( process, 1127 1174 new_pid, 1128 parent_process_xp,1129 1175 parent_process_xp ); 1130 1176 … … 1132 1178 cycle = (uint32_t)hal_get_cycles(); 1133 1179 if( DEBUG_PROCESS_MAKE_FORK < cycle ) 1134 printk("\n[DBG] %s : thread %x created child_process %x / child_pid %x / cycle %d\n", 1135 __FUNCTION__, CURRENT_THREAD, process, new_pid, cycle ); 1136 #endif 1180 printk("\n[DBG] %s : thread %x in process %x initialized child_process %x / cycle %d\n", 1181 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, new_pid, cycle ); 1182 #endif 1183 1184 // give TXT ownership to child process 1185 process_txt_set_ownership( XPTR( local_cxy , process ) ); 1137 1186 1138 1187 // copy VMM from parent descriptor to child descriptor … … 1151 1200 cycle = (uint32_t)hal_get_cycles(); 1152 1201 if( DEBUG_PROCESS_MAKE_FORK < cycle ) 1153 printk("\n[DBG] %s : thread %x copied VMM from parent %x to child %x / cycle %d\n", 1154 __FUNCTION__ , CURRENT_THREAD , parent_pid, new_pid, cycle ); 1155 #endif 1202 printk("\n[DBG] %s : thread %x in process %x copied VMM from parent %x to child %x / cycle %d\n", 1203 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, 1204 parent_pid, new_pid, cycle ); 1205 #endif 1206 1207 // parent process gives TXT ownership to child process if required 1208 if( process_txt_is_owner(parent_process_xp) ) 1209 { 1210 process_txt_set_ownership( XPTR( local_cxy , process ) ); 1211 1212 #if( DEBUG_PROCESS_MAKE_FORK & 1 ) 1213 cycle = (uint32_t)hal_get_cycles(); 1214 if( DEBUG_PROCESS_MAKE_EXEC < cycle ) 1215 printk("\n[DBG] %s : thread %x in process %x gives TXT from parent %x to child %x / cycle %d\n", 1216 __FUNCTION__ , CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, 1217 parent_pid, new_pid, cycle ); 1218 #endif 1219 1220 } 1156 1221 1157 1222 // update extended pointer on .elf file … … 1178 1243 cycle = (uint32_t)hal_get_cycles(); 1179 1244 if( DEBUG_PROCESS_MAKE_FORK < cycle ) 1180 printk("\n[DBG] %s : thread %x created child thread %x on core[%x,%d] / cycle %d\n", 1181 __FUNCTION__ , CURRENT_THREAD, thread, local_cxy, thread->core->lid, cycle ); 1245 printk("\n[DBG] %s : thread %x in process %x created main thread %x on core[%x,%d] / cycle %d\n", 1246 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, 1247 thread, local_cxy, thread->core->lid, cycle ); 1182 1248 #endif 1183 1249 … … 1200 1266 cycle = (uint32_t)hal_get_cycles(); 1201 1267 if( DEBUG_PROCESS_MAKE_FORK < cycle ) 1202 printk("\n[DBG] %s : thread %x set COW in parent and child / cycle %d\n",1203 __FUNCTION__ , CURRENT_THREAD, cycle );1268 printk("\n[DBG] %s : thread %x in process %x set COW in parent and child / cycle %d\n", 1269 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, cycle ); 1204 1270 #endif 1205 1271 … … 1222 1288 cycle = (uint32_t)hal_get_cycles(); 1223 1289 if( DEBUG_PROCESS_MAKE_FORK < cycle ) 1224 printk("\n[DBG] %s : thread %x exit/ cycle %d\n",1225 __FUNCTION__, CURRENT_THREAD , cycle );1290 printk("\n[DBG] %s : thread %x in process %x exit / created process %x / cycle %d\n", 1291 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, new_pid, cycle ); 1226 1292 #endif 1227 1293 … … 1229 1295 1230 1296 } // end process_make_fork() 1231 1232 1297 1233 1298 ///////////////////////////////////////////////////// 1234 1299 error_t process_make_exec( exec_info_t * exec_info ) 1235 1300 { 1236 char * path; // pathname to .elf file 1237 pid_t pid; // old_process PID, given to new_process 1238 pid_t temp_pid; // temporary PID / given to old_process 1239 process_t * old_process; // local pointer on old process 1240 thread_t * old_thread; // local pointer on old thread 1241 process_t * new_process; // local pointer on new process 1242 thread_t * new_thread; // local pointer on new thread 1243 xptr_t parent_xp; // extended pointer on parent process 1244 process_t * parent_ptr; // local pointer on parent process 1245 cxy_t parent_cxy; // parent process cluster identifier 1246 xptr_t children_lock_xp; // extended pointer on children lock in parent 1247 xptr_t children_root_xp; // extended pointer on children root in parent 1248 xptr_t children_nr_xp; // extended pointer on children number in parent 1249 thread_t * parent_main_ptr; // local pointer on parent main thread 1250 xptr_t parent_main_xp; // extended pointer on parent main thread 1251 pthread_attr_t attr; // new thread attributes 1252 lid_t lid; // selected core local index 1301 thread_t * thread; // local pointer on this thread 1302 process_t * process; // local pointer on this process 1303 pid_t pid; // this process identifier 1253 1304 error_t error; // value returned by called functions 1254 1255 // get old_thread, old_process & PID1256 old_thread = CURRENT_THREAD;1257 old_process = old_thread->process;1258 pid = old_process->pid;1259 1260 // get .elf pathname from exec_info 1261 path = exec_info->path;1262 1263 // this function must be executed by a thread running in owner cluster1264 assert( (CXY_FROM_PID( pid ) == local_cxy), __FUNCTION__, 1265 "local_cluster must be owner_cluster\n" ); 1266 1267 a ssert( (LTID_FROM_TRDID( old_thread->trdid ) == 0) , __FUNCTION__,1268 "must be called by the main thread\n" );1269 1305 char * path; // path to .elf file 1306 xptr_t file_xp; // extended pointer on .elf file descriptor 1307 uint32_t file_id; // file index in fd_array 1308 uint32_t args_nr; // number of main thread arguments 1309 char ** args_pointers; // array of pointers on main thread arguments 1310 1311 // get thread, process & PID 1312 thread = CURRENT_THREAD; 1313 process = thread->process; 1314 pid = process->pid; 1315 1316 // get relevant infos from exec_info 1317 path = exec_info->path; 1318 args_nr = exec_info->args_nr; 1319 args_pointers = exec_info->args_pointers; 1320 1270 1321 #if DEBUG_PROCESS_MAKE_EXEC 1271 1322 uint32_t cycle = (uint32_t)hal_get_cycles(); 1272 1323 if( DEBUG_PROCESS_MAKE_EXEC < cycle ) 1273 1324 printk("\n[DBG] %s : thread %x in process %x enters / path %s / cycle %d\n", 1274 __FUNCTION__, old_thread->trdid, pid, path, cycle ); 1275 #endif 1276 1277 // get parent process pointers 1278 parent_xp = old_process->parent_xp; 1279 parent_cxy = GET_CXY( parent_xp ); 1280 parent_ptr = GET_PTR( parent_xp ); 1281 1325 __FUNCTION__, thread->trdid, pid, path, cycle ); 1326 #endif 1327 1328 // open the file identified by <path> 1329 file_xp = XPTR_NULL; 1330 file_id = -1; 1331 error = vfs_open( process, 1332 path, 1333 O_RDONLY, 1334 0, 1335 &file_xp, 1336 &file_id ); 1337 if( error ) 1338 { 1339 printk("\n[ERROR] in %s : failed to open file <%s>\n", __FUNCTION__ , path ); 1340 return -1; 1341 } 1342 1282 1343 #if (DEBUG_PROCESS_MAKE_EXEC & 1) 1283 1344 if( DEBUG_PROCESS_MAKE_EXEC < cycle ) 1284 printk("\n[DBG] %s : thread %x in process %x get parent process %x in cluster %x\n", 1285 __FUNCTION__, old_thread->trdid, pid, parent_ptr, parent_cxy ); 1286 #endif 1287 1288 // get extended pointers on parent children_root, children_lock and children_nr 1289 children_root_xp = XPTR( parent_cxy , &parent_ptr->children_root ); 1290 children_lock_xp = XPTR( parent_cxy , &parent_ptr->children_lock ); 1291 children_nr_xp = XPTR( parent_cxy , &parent_ptr->children_nr ); 1292 1293 // get pointers on the parent process main thread 1294 parent_main_ptr = hal_remote_lpt( XPTR( parent_cxy , &parent_ptr->th_tbl[0] ) ); 1295 parent_main_xp = XPTR( parent_cxy , parent_main_ptr ); 1296 1297 // allocate memory for new_process descriptor 1298 new_process = process_alloc(); 1299 1300 if( new_process == NULL ) 1301 { 1302 printk("\n[ERROR] in %s : cannot allocate process for %s\n", __FUNCTION__ , path ); 1345 printk("\n[DBG] %s : open file <%s>\n", __FUNCTION__, path ); 1346 #endif 1347 1348 // delete all threads other than this main thread in all clusters 1349 process_sigaction( pid , DELETE_ALL_THREADS ); 1350 1351 // reset local process VMM 1352 vmm_destroy( process ); 1353 1354 #if( DEBUG_PROCESS_MAKE_EXEC & 1 ) 1355 cycle = (uint32_t)hal_get_cycles(); 1356 if( DEBUG_PROCESS_MAKE_EXEC < cycle ) 1357 printk("\n[DBG] %s : thread %x in process %x / reset VMM / cycle %d\n", 1358 __FUNCTION__, thread->trdid, pid, cycle ); 1359 #endif 1360 1361 // re-initialize the VMM (kentry/args/envs vsegs registration) 1362 error = vmm_init( process ); 1363 if( error ) 1364 { 1365 printk("\n[ERROR] in %s : cannot initialise VMM for %s\n", __FUNCTION__ , path ); 1366 vfs_close( file_xp , file_id ); 1367 // FIXME restore old process VMM 1303 1368 return -1; 1304 1369 } 1305 1306 // get a temporary PID for old_process 1307 error = cluster_pid_alloc( old_process , &temp_pid ); 1308 if( error ) 1309 { 1310 printk("\n[ERROR] in %s : cannot get PID in cluster %x\n", 1311 __FUNCTION__ , local_cxy ); 1312 process_free( new_process ); 1313 return -1; 1314 } 1315 1316 // set temporary PID to old_process 1317 old_process->pid = temp_pid; 1318 1319 // initialize new process descriptor 1320 process_reference_init( new_process, 1321 pid, 1322 parent_xp, // parent_process_xp 1323 XPTR(local_cxy , old_process) ); // model_process 1324 1325 // give TXT ownership to new_process 1326 process_txt_set_ownership( XPTR( local_cxy , new_process) ); 1327 1370 1328 1371 #if( DEBUG_PROCESS_MAKE_EXEC & 1 ) 1329 1372 cycle = (uint32_t)hal_get_cycles(); 1330 1373 if( DEBUG_PROCESS_MAKE_EXEC < cycle ) 1331 printk("\n[DBG] %s : thread %x in process %x created new process %x\n",1332 __FUNCTION__ , old_thread->trdid, pid, new_process);1333 #endif 1334 1335 // register code & data vsegs as well as entry-point in newprocess VMM,1374 printk("\n[DBG] %s : thread %x in process %x / kentry/args/envs vsegs registered / cycle %d\n", 1375 __FUNCTION__, thread->trdid, pid, cycle ); 1376 #endif 1377 1378 // register code & data vsegs as well as entry-point in process VMM, 1336 1379 // and register extended pointer on .elf file in process descriptor 1337 error = elf_load_process( path , new_process ); 1338 1380 error = elf_load_process( file_xp , process ); 1339 1381 if( error ) 1340 1382 { 1341 1383 printk("\n[ERROR] in %s : failed to access <%s>\n", __FUNCTION__ , path ); 1342 process_txt_set_ownership( XPTR( local_cxy , old_process) ); 1343 process_txt_detach( XPTR( local_cxy , new_process) ); 1344 process_destroy( new_process ); 1345 old_process->pid = pid; 1384 vfs_close( file_xp , file_id ); 1385 // FIXME restore old process VMM 1346 1386 return -1; 1347 1387 } … … 1350 1390 cycle = (uint32_t)hal_get_cycles(); 1351 1391 if( DEBUG_PROCESS_MAKE_EXEC < cycle ) 1352 printk("\n[DBG] %s : thread %x registered code/data vsegs in new process %x / cycle %d\n", 1353 __FUNCTION__, old_thread , new_process->pid , cycle ); 1354 #endif 1355 1356 // select a core in local cluster to execute the main thread 1357 lid = cluster_select_local_core(); 1358 1359 // initialize pthread attributes for main thread 1360 attr.attributes = PT_ATTR_DETACH | PT_ATTR_CLUSTER_DEFINED | PT_ATTR_CORE_DEFINED; 1361 attr.cxy = local_cxy; 1362 attr.lid = lid; 1363 1364 // create and initialize main thread in local cluster 1365 error = thread_user_create( pid, 1366 (void *)new_process->vmm.entry_point, 1367 exec_info->args_pointers, 1368 &attr, 1369 &new_thread ); 1370 if( error ) 1371 { 1372 printk("\n[ERROR] in %s : cannot create thread for %s\n", __FUNCTION__ , path ); 1373 process_txt_set_ownership( XPTR( local_cxy , old_process) ); 1374 process_txt_detach( XPTR( local_cxy , new_process) ); 1375 process_destroy( new_process ); 1376 old_process->pid = pid; 1392 printk("\n[DBG] %s : thread %x in process %x / code/data vsegs registered / cycle %d\n", 1393 __FUNCTION__, thread->trdid, pid, cycle ); 1394 #endif 1395 1396 // update the existing main thread descriptor... and jump to user code 1397 error = thread_user_exec( (void *)process->vmm.entry_point, 1398 args_nr, 1399 args_pointers ); 1400 if( error ) 1401 { 1402 printk("\n[ERROR] in %s : cannot reset main thread for %s\n", __FUNCTION__ , path ); 1403 vfs_close( file_xp , file_id ); 1404 // FIXME restore old process VMM 1377 1405 return -1; 1378 } 1379 1380 // check main thread LTID 1381 assert( (LTID_FROM_TRDID(new_thread->trdid) == 0) , __FUNCTION__ , 1382 "main thread must have LTID == 0\n" ); 1383 1384 #if( DEBUG_PROCESS_MAKE_EXEC & 1 ) 1385 cycle = (uint32_t)hal_get_cycles(); 1386 if( DEBUG_PROCESS_MAKE_EXEC < cycle ) 1387 printk("\n[DBG] %s : thread %x created new_process main thread %x / cycle %d\n", 1388 __FUNCTION__ , old_thread , new_thread , cycle ); 1389 #endif 1390 1391 // register new_process in parent children list 1392 remote_spinlock_lock( children_lock_xp ); 1393 xlist_add_last( children_root_xp , XPTR( local_cxy , &new_process->children_list ) ); 1394 hal_remote_atomic_add( children_nr_xp , 1 ); 1395 remote_spinlock_unlock( children_lock_xp ); 1396 1397 // activate new thread 1398 thread_unblock( XPTR( local_cxy , new_thread ) , THREAD_BLOCKED_GLOBAL ); 1399 1400 // detach old_process from TXT 1401 process_txt_detach( XPTR( local_cxy , old_process ) ); 1402 1403 // block old_thread 1404 thread_block( XPTR( local_cxy , old_thread ) , THREAD_BLOCKED_GLOBAL ); 1405 1406 // atomically update old_process termination state 1407 hal_atomic_or( &old_process->term_state , PROCESS_TERM_EXIT ); 1408 1409 // take the children lock and unblock the parent process main thread 1410 remote_spinlock_lock( children_lock_xp ); 1411 thread_unblock( parent_main_xp , THREAD_BLOCKED_WAIT ); 1412 remote_spinlock_unlock( children_lock_xp ); 1413 1414 hal_fence(); 1415 1416 #if DEBUG_PROCESS_MAKE_EXEC 1417 cycle = (uint32_t)hal_get_cycles(); 1418 if( DEBUG_PROCESS_MAKE_EXEC < cycle ) 1419 printk("\n[DBG] %s : old thread %x blocked for delete / new thread %x activated / cycle %d\n", 1420 __FUNCTION__ , old_thread , new_thread , cycle ); 1421 #endif 1422 1406 } 1407 1408 assert( false, __FUNCTION__, "we should not execute this code"); 1409 1423 1410 return 0; 1424 1411 1425 1412 } // end process_make_exec() 1413 1426 1414 1427 1415 /////////////////////////////////////////////// … … 1474 1462 pthread_attr_t attr; // main thread attributes 1475 1463 lid_t lid; // selected core local index for main thread 1464 xptr_t file_xp; // extended pointer on .elf file descriptor 1465 uint32_t file_id; // file index in fd_array 1476 1466 error_t error; 1477 1467 … … 1479 1469 uint32_t cycle = (uint32_t)hal_get_cycles(); 1480 1470 if( DEBUG_PROCESS_INIT_CREATE < cycle ) 1481 printk("\n[DBG] %s : thread %x enter / cycle %d\n", __FUNCTION__, CURRENT_THREAD, cycle ); 1471 printk("\n[DBG] %s : thread %x in process %x enter / cycle %d\n", 1472 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, cycle ); 1482 1473 #endif 1483 1474 1484 1475 // allocates memory for process descriptor from local cluster 1485 1476 process = process_alloc(); 1486 if( process == NULL ) 1487 { 1488 printk("\n[PANIC] in %s : no memory for process descriptor in cluster %x\n", 1489 __FUNCTION__, local_cxy ); 1490 } 1477 1478 assert( (process != NULL), __FUNCTION__, 1479 "no memory for process descriptor in cluster %x\n", local_cxy ); 1491 1480 1492 1481 // get PID from local cluster 1493 1482 error = cluster_pid_alloc( process , &pid ); 1494 if( error ) 1495 { 1496 printk("\n[PANIC] in %s : cannot allocate PID in cluster %x\n", 1497 __FUNCTION__, local_cxy ); 1498 process_free( process ); 1499 } 1500 1501 // check allocated PID 1502 assert( (pid == 1) , __FUNCTION__ , "process INIT must be first process in cluster 0\n" ); 1483 1484 assert( (error == 0), __FUNCTION__, 1485 "cannot allocate PID in cluster %x\n", local_cxy ); 1486 1487 assert( (pid == 1) , __FUNCTION__, 1488 "process INIT must be first process in cluster 0\n" ); 1503 1489 1504 1490 // initialize process descriptor / parent is local process_zero 1505 1491 process_reference_init( process, 1506 1492 pid, 1507 XPTR( local_cxy , &process_zero ), // parent 1508 XPTR( local_cxy , &process_zero ) ); // model 1493 XPTR( local_cxy , &process_zero ) ); 1494 1495 // open the file identified by CONFIG_PROCESS_INIT_PATH 1496 file_xp = XPTR_NULL; 1497 file_id = -1; 1498 error = vfs_open( process, 1499 CONFIG_PROCESS_INIT_PATH, 1500 O_RDONLY, 1501 0, 1502 &file_xp, 1503 &file_id ); 1504 1505 assert( (error == 0), __FUNCTION__, 1506 "failed to open file <%s>\n", CONFIG_PROCESS_INIT_PATH ); 1509 1507 1510 1508 // register "code" and "data" vsegs as well as entry-point 1511 1509 // in process VMM, using information contained in the elf file. 1512 if( elf_load_process( CONFIG_PROCESS_INIT_PATH , process ) ) 1513 { 1514 printk("\n[PANIC] in %s : cannot access .elf file / path = %s\n", 1515 __FUNCTION__, CONFIG_PROCESS_INIT_PATH ); 1516 process_destroy( process ); 1517 } 1510 error = elf_load_process( file_xp , process ); 1511 1512 assert( (error == 0), __FUNCTION__, 1513 "cannot access .elf file <%s>\n", CONFIG_PROCESS_INIT_PATH ); 1518 1514 1519 1515 // get extended pointers on process_zero children_root, children_lock … … 1541 1537 &attr, 1542 1538 &thread ); 1543 if( error ) 1544 { 1545 printk("\n[PANIC] in %s : cannot create main thread / path = %s\n", 1546 __FUNCTION__, CONFIG_PROCESS_INIT_PATH ); 1547 process_destroy( process ); 1548 } 1549 1550 // check main thread index 1551 assert( (thread->trdid == 0) , __FUNCTION__ , "main thread must have index 0\n" ); 1539 1540 assert( (error == 0), __FUNCTION__, 1541 "cannot create main thread for <%s>\n", CONFIG_PROCESS_INIT_PATH ); 1542 1543 assert( (thread->trdid == 0), __FUNCTION__, 1544 "main thread must have index 0 for <%s>\n", CONFIG_PROCESS_INIT_PATH ); 1552 1545 1553 1546 // activate thread … … 1559 1552 cycle = (uint32_t)hal_get_cycles(); 1560 1553 if( DEBUG_PROCESS_INIT_CREATE < cycle ) 1561 printk("\n[DBG] %s : thread %x exit / cycle %d\n", __FUNCTION__, CURRENT_THREAD, cycle ); 1554 printk("\n[DBG] %s : thread %x in process %x exit / cycle %d\n", 1555 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, cycle ); 1562 1556 #endif 1563 1557 … … 1702 1696 xptr_t lock_xp; // extended pointer on list lock in chdev 1703 1697 1704 #if DEBUG_PROCESS_TXT1705 uint32_t cycle = (uint32_t)hal_get_cycles();1706 if( DEBUG_PROCESS_TXT < cycle )1707 printk("\n[DBG] %s : thread %x enter for process %x / txt_id = %d / cycle %d\n",1708 __FUNCTION__, CURRENT_THREAD, process->pid, txt_id, cycle );1709 #endif1710 1711 1698 // check process is in owner cluster 1712 1699 assert( (CXY_FROM_PID( process->pid ) == local_cxy) , __FUNCTION__ , … … 1732 1719 1733 1720 #if DEBUG_PROCESS_TXT 1734 cycle = (uint32_t)hal_get_cycles();1721 uint32_t cycle = (uint32_t)hal_get_cycles(); 1735 1722 if( DEBUG_PROCESS_TXT < cycle ) 1736 printk("\n[DBG] %s : thread %x exit for process %x / txt_id = %d / cycle %d\n", 1737 __FUNCTION__, CURRENT_THREAD, process->pid, txt_id , cycle ); 1723 printk("\n[DBG] %s : thread %x in process %x attached process %x to TXT %d / cycle %d\n", 1724 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, 1725 process->pid, txt_id , cycle ); 1738 1726 #endif 1739 1727 … … 1755 1743 process_cxy = GET_CXY( process_xp ); 1756 1744 process_ptr = GET_PTR( process_xp ); 1745 1746 // check process descriptor in owner cluster 1757 1747 process_pid = hal_remote_lw( XPTR( process_cxy , &process_ptr->pid ) ); 1758 1759 // check process descriptor in owner cluster1760 1748 assert( (CXY_FROM_PID( process_pid ) == process_cxy ) , __FUNCTION__ , 1761 1749 "process descriptor not in owner cluster" ); 1762 1763 #if DEBUG_PROCESS_TXT1764 uint32_t cycle = (uint32_t)hal_get_cycles();1765 if( DEBUG_PROCESS_TXT < cycle )1766 printk("\n[DBG] %s : thread %x enter for process %x / cycle %d\n",1767 __FUNCTION__, CURRENT_THREAD, process_pid, cycle );1768 #endif1769 1750 1770 1751 // release TXT ownership (does nothing if not TXT owner) … … 1788 1769 1789 1770 #if DEBUG_PROCESS_TXT 1790 cycle = (uint32_t)hal_get_cycles();1771 uint32_t cycle = (uint32_t)hal_get_cycles(); 1791 1772 uint32_t txt_id = hal_remote_lw( XPTR( chdev_cxy , &chdev_ptr->channel ) ); 1792 1773 if( DEBUG_PROCESS_TXT < cycle ) 1793 printk("\n[DBG] %s : thread %x exit / process %x detached from TXT %d / cycle %d\n", 1794 __FUNCTION__, CURRENT_THREAD, process_pid, txt_id, cycle ); 1774 printk("\n[DBG] %s : thread %x in process %x detached process %x from TXT %d / cycle %d\n", 1775 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, 1776 process_pid, txt_id, cycle ); 1795 1777 #endif 1796 1778 … … 1811 1793 process_cxy = GET_CXY( process_xp ); 1812 1794 process_ptr = GET_PTR( process_xp ); 1813 1814 // get process PID1815 1795 process_pid = hal_remote_lw( XPTR( process_cxy , &process_ptr->pid ) ); 1816 1796 … … 1818 1798 assert( (process_cxy == CXY_FROM_PID( process_pid )) , __FUNCTION__, 1819 1799 "process descriptor not in owner cluster\n" ); 1820 1821 #if DEBUG_PROCESS_TXT1822 uint32_t cycle = (uint32_t)hal_get_cycles();1823 if( DEBUG_PROCESS_TXT < cycle )1824 printk("\n[DBG] %s : thread %x enter for process %x / cycle %d\n",1825 __FUNCTION__, CURRENT_THREAD, process_pid, cycle );1826 #endif1827 1800 1828 1801 // get extended pointer on stdin pseudo file … … 1838 1811 1839 1812 #if DEBUG_PROCESS_TXT 1840 cycle = (uint32_t)hal_get_cycles(); 1813 uint32_t cycle = (uint32_t)hal_get_cycles(); 1814 uint32_t txt_id = hal_remote_lw( XPTR( txt_cxy , &txt_ptr->channel ) ); 1841 1815 if( DEBUG_PROCESS_TXT < cycle ) 1842 printk("\n[DBG] %s : thread %x exit forprocess %x / cycle %d\n",1843 __FUNCTION__, CURRENT_THREAD , process_pid, cycle );1816 printk("\n[DBG] %s : thread %x in process %x give TXT %d to process %x / cycle %d\n", 1817 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, txt_id, process_pid, cycle ); 1844 1818 #endif 1845 1819 … … 1865 1839 cxy_t current_cxy; // cluster for current process 1866 1840 1841 #if DEBUG_PROCESS_TXT 1842 uint32_t cycle; 1843 #endif 1844 1867 1845 // get pointers on process in owner cluster 1868 1846 process_cxy = GET_CXY( process_xp ); 1869 1847 process_ptr = GET_PTR( process_xp ); 1870 1871 // get process PID1872 1848 process_pid = hal_remote_lw( XPTR( process_cxy , &process_ptr->pid ) ); 1873 1849 … … 1875 1851 assert( (process_cxy == CXY_FROM_PID( process_pid )) , __FUNCTION__, 1876 1852 "process descriptor not in owner cluster\n" ); 1877 1878 #if DEBUG_PROCESS_TXT1879 uint32_t cycle = (uint32_t)hal_get_cycles();1880 if( DEBUG_PROCESS_TXT < cycle )1881 printk("\n[DBG] %s : thread %x enter / process %x / cycle %d\n",1882 __FUNCTION__, CURRENT_THREAD, process_pid, cycle );1883 #endif1884 1853 1885 1854 // get extended pointer on stdin pseudo file … … 1895 1864 txt_id = hal_remote_lw ( XPTR( txt_cxy , &txt_ptr->channel ) ); 1896 1865 1897 #if( DEBUG_PROCESS_TXT & 1 )1898 if( DEBUG_PROCESS_TXT < cycle )1899 printk("\n[DBG] %s : file_ptr %x / txt_ptr %x / txt_id %d / owner_ptr = %x\n",1900 __FUNCTION__, GET_PTR(file_xp), txt_ptr, txt_id, GET_PTR(owner_xp) );1901 #endif1902 1903 1866 // transfer ownership only if process is the TXT owner 1904 1867 if( (owner_xp == process_xp) && (txt_id > 0) ) … … 1913 1876 if( process_get_ppid( process_xp ) != 1 ) // process is not KSH 1914 1877 { 1915 1916 #if( DEBUG_PROCESS_TXT & 1 )1917 if( DEBUG_PROCESS_TXT < cycle )1918 printk("\n[DBG] %s : process is not the KSH process => search the KSH\n", __FUNCTION__ );1919 #endif1920 1878 // scan attached process list to find KSH process 1921 1879 XLIST_FOREACH( root_xp , iter_xp ) … … 1934 1892 1935 1893 #if DEBUG_PROCESS_TXT 1936 cycle = (uint32_t)hal_get_cycles(); 1894 cycle = (uint32_t)hal_get_cycles(); 1895 uint32_t ksh_pid = hal_remote_lw( XPTR( current_cxy , ¤t_ptr->pid ) ); 1937 1896 if( DEBUG_PROCESS_TXT < cycle ) 1938 printk("\n[DBG] %s : thread %x exit / process %x to KSH process%x / cycle %d\n",1939 __FUNCTION__, CURRENT_THREAD , process_pid,1940 hal_remote_lw( XPTR( current_cxy , ¤t_ptr->pid ) ), cycle);1897 printk("\n[DBG] %s : thread %x in process %x release TXT %d to KSH %x / cycle %d\n", 1898 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, txt_id, ksh_pid, cycle ); 1899 process_txt_display( txt_id ); 1941 1900 #endif 1942 1901 return; … … 1954 1913 else // process is KSH 1955 1914 { 1956 1957 #if( DEBUG_PROCESS_TXT & 1 )1958 if( DEBUG_PROCESS_TXT < cycle )1959 printk("\n[DBG] %s : process is the KSH process => search another\n", __FUNCTION__ );1960 #endif1961 1962 1915 // scan attached process list to find another process 1963 1916 XLIST_FOREACH( root_xp , iter_xp ) … … 1976 1929 1977 1930 #if DEBUG_PROCESS_TXT 1978 cycle = (uint32_t)hal_get_cycles(); 1931 cycle = (uint32_t)hal_get_cycles(); 1932 uint32_t new_pid = hal_remote_lw( XPTR( current_cxy , ¤t_ptr->pid ) ); 1979 1933 if( DEBUG_PROCESS_TXT < cycle ) 1980 printk("\n[DBG] %s : thread %x exit / KSH process %xto process %x / cycle %d\n",1981 __FUNCTION__, CURRENT_THREAD , process_pid,1982 hal_remote_lw( XPTR( current_cxy , ¤t_ptr->pid ) ), cycle);1934 printk("\n[DBG] %s : thread %x in process %x release TXT %d to process %x / cycle %d\n", 1935 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, txt_id, new_pid, cycle ); 1936 process_txt_display( txt_id ); 1983 1937 #endif 1984 1938 return; … … 1995 1949 cycle = (uint32_t)hal_get_cycles(); 1996 1950 if( DEBUG_PROCESS_TXT < cycle ) 1997 printk("\n[DBG] %s : thread %x exit / KSH process %x to nobody / cycle %d\n", 1998 __FUNCTION__, CURRENT_THREAD, process_pid, cycle ); 1951 printk("\n[DBG] %s : thread %x in process %x release TXT %d to nobody / cycle %d\n", 1952 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, txt_id, cycle ); 1953 process_txt_display( txt_id ); 1999 1954 #endif 2000 1955 return; … … 2007 1962 cycle = (uint32_t)hal_get_cycles(); 2008 1963 if( DEBUG_PROCESS_TXT < cycle ) 2009 printk("\n[DBG] %s : thread %x exit / process %x is not TXT owner / cycle %d\n", 2010 __FUNCTION__, CURRENT_THREAD, process_pid, cycle ); 1964 printk("\n[DBG] %s : thread %x in process %d does nothing (not TXT owner) / cycle %d\n", 1965 __FUNCTION__, CURRENT_THREAD->trdid, process_pid, cycle ); 1966 process_txt_display( txt_id ); 2011 1967 #endif 2012 1968 … … 2014 1970 } // end process_txt_transfer_ownership() 2015 1971 1972 1973 ////////////////////////////////////////////////// 1974 uint32_t process_txt_is_owner( xptr_t process_xp ) 1975 { 1976 // get local pointer and cluster of process in owner cluster 1977 cxy_t process_cxy = GET_CXY( process_xp ); 1978 process_t * process_ptr = GET_PTR( process_xp ); 1979 1980 // check owner cluster 1981 pid_t process_pid = hal_remote_lw( XPTR( process_cxy , &process_ptr->pid ) ); 1982 assert( (process_cxy == CXY_FROM_PID( process_pid )) , __FUNCTION__, 1983 "process descriptor not in owner cluster\n" ); 1984 1985 // get extended pointer on stdin pseudo file 1986 xptr_t file_xp = hal_remote_lwd( XPTR( process_cxy , &process_ptr->fd_array.array[0] ) ); 1987 1988 // get pointers on TXT chdev 1989 xptr_t txt_xp = chdev_from_file( file_xp ); 1990 cxy_t txt_cxy = GET_CXY( txt_xp ); 1991 chdev_t * txt_ptr = GET_PTR( txt_xp ); 1992 1993 // get extended pointer on TXT_RX owner process 1994 xptr_t owner_xp = hal_remote_lwd( XPTR( txt_cxy , &txt_ptr->ext.txt.owner_xp ) ); 1995 1996 return (process_xp == owner_xp); 1997 1998 } // end process_txt_is_owner() 2016 1999 2017 2000 //////////////////////////////////////////////// … … 2023 2006 2024 2007 return (xptr_t)hal_remote_lwd( XPTR( txt_rx_cxy , &txt_rx_ptr->ext.txt.owner_xp ) ); 2025 } 2008 2009 } // end process_txt_get_owner() 2026 2010 2027 2011 /////////////////////////////////////////// -
trunk/kernel/kern/process.h
r450 r457 29 29 #include <kernel_config.h> 30 30 #include <errno.h> 31 #include <hal_ types.h>31 #include <hal_kernel_types.h> 32 32 #include <list.h> 33 33 #include <xlist.h> … … 146 146 147 147 uint32_t term_state; /*! termination status (flags & exit status) */ 148 149 bool_t txt_owner; /*! current TXT owner */150 148 } 151 149 process_t; … … 213 211 /********************************************************************************************* 214 212 * This function initializes a local, reference, user process descriptor from another process 215 * descriptor, defined by the <model_xp> argument. The <process> and <pid> arguments must 216 * be previously allocated by he caller. This function can be called by three functions: 217 * 1) process_init_create() : process is the reference INIT process / pid = 1 / 218 * the parent and model process descriptors are both the kernel process_zero. 219 * 2) process_make_fork() : the model process descriptor is the (generally remote) 220 * parent process. 221 * 3) process_make exec() : the model process is the local old_process, the new_process 222 * parent is the same as the old_process parent. 213 * descriptor, defined by the <parent_xp> argument. The <process> and <pid> arguments must 214 * be previously allocated by the caller. This function can be called by two functions: 215 * 1) process_init_create() : process is the INIT process; parent is process-zero. 216 * 2) process_make_fork() : the parent process descriptor is generally remote. 223 217 * The following fields are initialised : 224 218 * - It set the pid / ppid / ref_xp / parent_xp / state fields. 225 219 * - It initializes the VMM (register the kentry, args, envs vsegs in VSL) 226 220 * - It initializes the FDT, defining the three pseudo files STDIN / STDOUT / STDERR. 221 * . if INIT process => link to kernel TXT[0]. 222 * . if KSH[i] process => allocate a free TXT[i] and give TXT ownership. 223 * . if USER process => same TXT[i] as parent process and give TXT ownership. 227 224 * - It set the root_xp, bin_xp, cwd_xp fields. 228 225 * - It reset the children list as empty, but does NOT register it in parent children list. … … 236 233 * @ pid : [in] process identifier. 237 234 * @ parent_xp : [in] extended pointer on parent process descriptor. 238 * @ model_xp : [in] extended pointer on model process descriptor.239 235 ********************************************************************************************/ 240 236 void process_reference_init( process_t * process, 241 237 pid_t pid, 242 xptr_t parent_xp, 243 xptr_t model_xp ); 238 xptr_t parent_xp ); 244 239 245 240 /********************************************************************************************* … … 515 510 * It is called only by the process_reference_init() function when creating a KSH process. 516 511 * It makes a kernel panic if no free TXT terminal is found. 517 * The allocated TXT terminal is only released if the KSH process is deleted, 518 * which is a rare and abnormal event. 512 * The allocated TXT terminal is only released when the KSH process is deleted. 519 513 ********************************************************************************************* 520 514 * @ return TXT terminal index if succes / kernel panic if no terminal found. … … 547 541 548 542 /********************************************************************************************* 549 * This function gives t o a process identified by the <owner_xp> argument, and attached550 * to terminal TXT[i] the exclusive ownership of the TXT_RX[i] terminal.551 * The process descriptor must be in the process owner cluster.543 * This function gives the TXT ownership to a process identified by the <process_xp> argument. 544 * It can be called by a thread running in any cluster, but the <process_xp> must be the 545 * owner cluster process descriptor. 552 546 ********************************************************************************************* 553 547 * @ owner_xp : extended pointer on process descriptor in owner cluster. 554 548 ********************************************************************************************/ 555 void process_txt_set_ownership( xptr_t owner_xp );556 557 /********************************************************************************************* 558 * When the process dentified by the <owner_xp> argument has the exclusive ownership of549 void process_txt_set_ownership( xptr_t process_xp ); 550 551 /********************************************************************************************* 552 * When the process identified by the <owner_xp> argument has the exclusive ownership of 559 553 * the TXT_RX terminal, this function transfer this ownership to another attached process. 560 554 * The process descriptor must be the process owner. … … 565 559 * - If there is no other attached process, the TXT has no more defined owner. 566 560 ********************************************************************************************* 567 * @ owner_xp : extended pointer on process descriptor in owner cluster. 568 ********************************************************************************************/ 569 void process_txt_transfer_ownership( xptr_t owner_xp ); 570 571 /********************************************************************************************* 572 * This function returns the TXT owner process (foreground process) 573 * for a given TXT terminal identified by its <channel> index. 574 ********************************************************************************************* 575 * @ channel : TXT terminal channel. 576 * @ return extentded pointer on TXT owner process in owner cluster. 561 * @ process_xp : extended pointer on process descriptor in owner cluster. 562 ********************************************************************************************/ 563 void process_txt_transfer_ownership( xptr_t process_xp ); 564 565 /********************************************************************************************* 566 * This function returns true if the process identified by the <process_xp> argument 567 * is the TXT owner. It can be called by a thread running in any cluster, but the 568 * process_xp must be the owner cluster process descriptor. 569 ********************************************************************************************* 570 * @ return a non-zero value if target process is TXT owner. 571 ********************************************************************************************/ 572 uint32_t process_txt_is_owner( xptr_t process_xp ); 573 574 /********************************************************************************************* 575 * This function returns an extended ponter on the current TXT owner process, 576 * for the TXT terminal identified by the <channel> index. 577 ********************************************************************************************* 578 * @ channel : TXT channel. 579 * @ return extended pointer on TXT owner process. 577 580 ********************************************************************************************/ 578 581 xptr_t process_txt_get_owner( uint32_t channel ); -
trunk/kernel/kern/rpc.c
r450 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_atomic.h> 27 27 #include <hal_remote.h> … … 100 100 volatile error_t full; 101 101 thread_t * this; 102 cluster_t * cluster;103 104 #if DEBUG_RPC_CLIENT_GENERIC105 uint32_t cycle = (uint32_t)hal_get_cycles();106 if( DEBUG_RPC_CLIENT_GENERIC < cycle )107 printk("\n[DBG] %s : thread %x in cluster %x enter for rpc[%d] / rpc_ptr %x / cycle %d\n",108 __FUNCTION__, CURRENT_THREAD, local_cxy, rpc->index, rpc, cycle );109 #endif110 102 111 103 full = 0; 112 104 this = CURRENT_THREAD; 113 cluster = LOCAL_CLUSTER;114 105 client_core_lid = this->core->lid; 115 106 107 #if DEBUG_RPC_CLIENT_GENERIC 108 uint32_t cycle = (uint32_t)hal_get_cycles(); 109 if( DEBUG_RPC_CLIENT_GENERIC < cycle ) 110 printk("\n[DBG] %s : thread %x in process %x enter for rpc[%d] / cycle %d\n", 111 __FUNCTION__, this->trdid, this->process->pid, rpc->index, cycle ); 112 #endif 113 116 114 // select a server_core : use client core index if possible / core 0 otherwise 117 if( client_core_lid < hal_remote_lw( XPTR( server_cxy , & cluster->cores_nr ) ) )115 if( client_core_lid < hal_remote_lw( XPTR( server_cxy , &LOCAL_CLUSTER->cores_nr ) ) ) 118 116 { 119 117 server_core_lid = client_core_lid; … … 150 148 151 149 hal_fence(); 150 151 #if DEBUG_RPC_CLIENT_GENERIC 152 cycle = (uint32_t)hal_get_cycles(); 153 if( DEBUG_RPC_CLIENT_GENERIC < cycle ) 154 printk("\n[DBG] %s : thread %x in process %x / rpc[%d] / rpc_ptr %x / cycle %d\n", 155 __FUNCTION__, this->trdid, this->process->pid, rpc->index, rpc, cycle ); 156 #endif 152 157 153 154 158 // send IPI to the selected server core 159 dev_pic_send_ipi( server_cxy , server_core_lid ); 155 160 156 161 // wait RPC completion before returning if blocking RPC … … 165 170 cycle = (uint32_t)hal_get_cycles(); 166 171 if( DEBUG_RPC_CLIENT_GENERIC < cycle ) 167 printk("\n[DBG] %s : thread %x in cluster %x busy waiting /rpc[%d] / cycle %d\n",168 __FUNCTION__, CURRENT_THREAD, local_cxy, rpc->index , cycle );172 printk("\n[DBG] %s : thread %x in process %x busy waiting for rpc[%d] / cycle %d\n", 173 __FUNCTION__, this->trdid, this->process->pid, rpc->index , cycle ); 169 174 #endif 170 175 … … 174 179 cycle = (uint32_t)hal_get_cycles(); 175 180 if( DEBUG_RPC_CLIENT_GENERIC < cycle ) 176 printk("\n[DBG] %s : thread %x in cluster %x resumes /rpc[%d] / cycle %d\n",177 __FUNCTION__, CURRENT_THREAD, local_cxy, rpc->index, cycle );181 printk("\n[DBG] %s : thread %x in process %x resumes for rpc[%d] / cycle %d\n", 182 __FUNCTION__, this->trdid, this->process->pid, rpc->index, cycle ); 178 183 #endif 179 184 } … … 184 189 cycle = (uint32_t)hal_get_cycles(); 185 190 if( DEBUG_RPC_CLIENT_GENERIC < cycle ) 186 printk("\n[DBG] %s : thread %x in cluster %x blocks & deschedules /rpc[%d] / cycle %d\n",187 __FUNCTION__, CURRENT_THREAD, local_cxy, rpc->index , cycle );191 printk("\n[DBG] %s : thread %x in process %x blocks & deschedules for rpc[%d] / cycle %d\n", 192 __FUNCTION__, this->trdid, this->process->pid, rpc->index , cycle ); 188 193 #endif 189 194 thread_block( XPTR( local_cxy , this ) , THREAD_BLOCKED_RPC ); … … 193 198 cycle = (uint32_t)hal_get_cycles(); 194 199 if( DEBUG_RPC_CLIENT_GENERIC < cycle ) 195 printk("\n[DBG] %s : thread %x in cluster %x resumes / rpcr[%d] / cycle %d\n",196 __FUNCTION__, CURRENT_THREAD, local_cxy, rpc->index, cycle );200 printk("\n[DBG] %s : thread %x in process %x resumes for rpc[%d] / cycle %d\n", 201 __FUNCTION__, this->trdid, this->process->pid, rpc->index, cycle ); 197 202 #endif 198 203 } … … 207 212 cycle = (uint32_t)hal_get_cycles(); 208 213 if( DEBUG_RPC_CLIENT_GENERIC < cycle ) 209 printk("\n[DBG] %s : non blocking rpc[%d] => thread %x return/ cycle %d\n",210 __FUNCTION__, rpc->index, CURRENT_THREAD, cycle );214 printk("\n[DBG] %s : thread %x in process %x returns for non blocking rpc[%d] / cycle %d\n", 215 __FUNCTION__, this->trdid, this->process->pid, rpc->index, cycle ); 211 216 #endif 212 217 … … 225 230 thread_t * thread; 226 231 uint32_t sr_save; 232 233 #if DEBUG_RPC_SERVER_GENERIC 234 uint32_t cycle; 235 #endif 227 236 228 237 bool_t found = false; … … 232 241 remote_fifo_t * rpc_fifo = &LOCAL_CLUSTER->rpc_fifo[core->lid]; 233 242 234 #if DEBUG_RPC_SERVER_GENERIC235 uint32_t cycle = (uint32_t)hal_get_cycles();236 if( DEBUG_RPC_SERVER_GENERIC < cycle )237 printk("\n[DBG] %s : thread %x interrupted in cluster %x / cycle %d\n",238 __FUNCTION__, this, local_cxy, cycle );239 #endif240 241 243 // interrupted thread not preemptable during RPC chek 242 244 hal_disable_irq( &sr_save ); … … 249 251 cycle = (uint32_t)hal_get_cycles(); 250 252 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 251 printk("\n[DBG] %s : RPC FIFO non empty in cluster %x/ cycle %d\n",252 __FUNCTION__, local_cxy, c ycle );253 printk("\n[DBG] %s : RPC FIFO non empty for core[%x,%d] / cycle %d\n", 254 __FUNCTION__, local_cxy, core->lid, cycle ); 253 255 #endif 254 256 … … 290 292 cycle = (uint32_t)hal_get_cycles(); 291 293 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 292 printk("\n[DBG] %s : create a new RPC thread %x in cluster %x/ cycle %d\n",293 __FUNCTION__, thread, local_cxy, c ycle );294 printk("\n[DBG] %s : new RPC thread %x created for core[%x,%d] / cycle %d\n", 295 __FUNCTION__, thread, local_cxy, core->lid, cycle ); 294 296 #endif 295 297 } … … 299 301 cycle = (uint32_t)hal_get_cycles(); 300 302 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 301 printk("\n[DBG] %s : interrupted thread %x deschedules in cluster %x/ cycle %d\n",302 __FUNCTION__, this, local_cxy, c ycle );303 printk("\n[DBG] %s : interrupted thread %x deschedules on core[%x,%d] / cycle %d\n", 304 __FUNCTION__, this, local_cxy, core->lid, cycle ); 303 305 #endif 304 306 … … 309 311 cycle = (uint32_t)hal_get_cycles(); 310 312 if( DEBUG_RPC_SERVER_GENERIC < cycle ) 311 printk("\n[DBG] %s : interrupted thread %x resumes in cluster %x/ cycle %d\n",312 __FUNCTION__, this, local_cxy, c ycle );313 printk("\n[DBG] %s : interrupted thread %x resumes on core[%x,%d] / cycle %d\n", 314 __FUNCTION__, this, local_cxy, core->lid, cycle ); 313 315 #endif 314 316 … … 410 412 #endif 411 413 // send IPI to client core 412 dev_pic_send_ipi( desc_cxy , client_core_lid );414 // dev_pic_send_ipi( desc_cxy , client_core_lid ); 413 415 } 414 416 } … … 872 874 pid_t pid = rpc->args[1]; 873 875 if( DEBUG_RPC_PROCESS_SIGACTION < cycle ) 874 printk("\n[DBG] %s : enter to %sprocess %x in cluster %x / cycle %d\n",876 printk("\n[DBG] %s : enter to request %s of process %x in cluster %x / cycle %d\n", 875 877 __FUNCTION__ , process_action_str( action ) , pid , cxy , cycle ); 876 878 #endif … … 949 951 950 952 // send an IPI to client core 951 dev_pic_send_ipi( client_cxy , client_lid );953 // dev_pic_send_ipi( client_cxy , client_lid ); 952 954 } 953 955 -
trunk/kernel/kern/rpc.h
r450 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <hal_atomic.h> 30 30 #include <bits.h> -
trunk/kernel/kern/scheduler.c
r450 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_switch.h> 27 27 #include <hal_irqmask.h> -
trunk/kernel/kern/scheduler.h
r450 r457 25 25 #define _SCHEDULER_H_ 26 26 27 #include <hal_ types.h>27 #include <hal_kernel_types.h> 28 28 #include <list.h> 29 29 #include <spinlock.h> -
trunk/kernel/kern/signal.c
r409 r457 24 24 */ 25 25 26 #include <hal_ types.h>26 #include <hal_kernel_types.h> 27 27 #include <printk.h> 28 28 #include <signal.h> -
trunk/kernel/kern/signal.h
r435 r457 27 27 #define _SIGNAL_H_ 28 28 29 #include <hal_ types.h>29 #include <hal_kernel_types.h> 30 30 31 31 -
trunk/kernel/kern/thread.c
r450 r457 24 24 25 25 #include <kernel_config.h> 26 #include <hal_ types.h>26 #include <hal_kernel_types.h> 27 27 #include <hal_context.h> 28 28 #include <hal_irqmask.h> … … 167 167 thread->quantum = 0; // TODO 168 168 thread->ticks_nr = 0; // TODO 169 thread->time_last_check = 0; 169 thread->time_last_check = 0; // TODO 170 170 thread->core = &local_cluster->core_tbl[core_lid]; 171 171 thread->process = process; … … 243 243 uint32_t cycle = (uint32_t)hal_get_cycles(); 244 244 if( DEBUG_THREAD_USER_CREATE < cycle ) 245 printk("\n[DBG] %s : thread %x enter for process %xin cluster %x / cycle %d\n",246 __FUNCTION__, CURRENT_THREAD , pid , local_cxy , cycle );245 printk("\n[DBG] %s : thread %x in process %x enter in cluster %x / cycle %d\n", 246 __FUNCTION__, CURRENT_THREAD->trdid, pid , local_cxy , cycle ); 247 247 #endif 248 248 … … 301 301 } 302 302 303 #if( DEBUG_THREAD_USER_CREATE & 1) 304 if( DEBUG_THREAD_USER_CREATE < cycle ) 305 printk("\n[DBG] %s : stack vseg created / vpn_base %x / %d pages\n", 306 __FUNCTION__, vseg->vpn_base, vseg->vpn_size ); 307 #endif 308 303 309 // allocate memory for thread descriptor 304 310 thread = thread_alloc(); … … 313 319 #if( DEBUG_THREAD_USER_CREATE & 1) 314 320 if( DEBUG_THREAD_USER_CREATE < cycle ) 315 printk("\n[DBG] %s : thread descriptor %x allocated\n",321 printk("\n[DBG] %s : new thread descriptor %x allocated\n", 316 322 __FUNCTION__, thread ); 317 323 #endif … … 336 342 #if( DEBUG_THREAD_USER_CREATE & 1) 337 343 if( DEBUG_THREAD_USER_CREATE < cycle ) 338 printk("\n[DBG] %s : thread descriptor %x initialised / trdid =%x\n",339 __FUNCTION__, thread , thread->trdid );344 printk("\n[DBG] %s : new thread descriptor initialised / trdid %x\n", 345 __FUNCTION__, thread->trdid ); 340 346 #endif 341 347 … … 347 353 348 354 // allocate & initialize CPU context 349 if( hal_cpu_context_ create( thread ) )355 if( hal_cpu_context_alloc( thread ) ) 350 356 { 351 357 printk("\n[ERROR] in %s : cannot create CPU context\n", __FUNCTION__ ); … … 354 360 return ENOMEM; 355 361 } 356 357 // allocate FPU context 362 hal_cpu_context_init( thread ); 363 364 // allocate & initialize FPU context 358 365 if( hal_fpu_context_alloc( thread ) ) 359 366 { … … 363 370 return ENOMEM; 364 371 } 372 hal_fpu_context_init( thread ); 373 374 #if( DEBUG_THREAD_USER_CREATE & 1) 375 if( DEBUG_THREAD_USER_CREATE < cycle ) 376 printk("\n[DBG] %s : CPU & FPU contexts created\n", 377 __FUNCTION__, thread->trdid ); 378 vmm_display( process , true ); 379 #endif 365 380 366 381 #if DEBUG_THREAD_USER_CREATE 367 382 cycle = (uint32_t)hal_get_cycles(); 368 383 if( DEBUG_THREAD_USER_CREATE < cycle ) 369 printk("\n[DBG] %s : thread %x exit / new_thread %x in process%x / core %d / cycle %d\n",370 __FUNCTION__, CURRENT_THREAD , thread->trdid , pid, core_lid, cycle );384 printk("\n[DBG] %s : thread %x in process %x exit / new_thread %x / core %d / cycle %d\n", 385 __FUNCTION__, CURRENT_THREAD->trdid , pid, thread->trdid, core_lid, cycle ); 371 386 #endif 372 387 … … 554 569 } // end thread_user_fork() 555 570 571 //////////////////////////////////////////////// 572 error_t thread_user_exec( void * entry_func, 573 uint32_t argc, 574 char ** argv ) 575 { 576 thread_t * thread = CURRENT_THREAD; 577 process_t * process = thread->process; 578 579 #if DEBUG_THREAD_USER_EXEC 580 uint32_t cycle = (uint32_t)hal_get_cycles(); 581 if( DEBUG_THREAD_USER_EXEC < cycle ) 582 printk("\n[DBG] %s : thread %x in process %x enter / cycle %d\n", 583 __FUNCTION__, thread->trdid, process->pid, cycle ); 584 #endif 585 586 assert( (thread->type == THREAD_USER ) , __FUNCTION__, "bad type" ); 587 assert( (thread->signature == THREAD_SIGNATURE) , __FUNCTION__, "bad signature" ); 588 assert( (thread->local_locks == 0) , __FUNCTION__, "bad local locks" ); 589 assert( (thread->remote_locks == 0) , __FUNCTION__, "bad remote locks" ); 590 591 // re-initialize various thread descriptor fields 592 thread->quantum = 0; // TODO 593 thread->ticks_nr = 0; // TODO 594 thread->time_last_check = 0; // TODO 595 596 #if CONFIG_LOCKS_DEBUG 597 list_root_init( &thread->locks_root ); 598 xlist_root_init( XPTR( local_cxy , &thread->xlocks_root ) ); 599 #endif 600 601 thread->entry_func = entry_func; 602 thread->main_argc = argc; 603 thread->main_argv = argv; 604 605 // the main thread is always detached 606 thread->flags = THREAD_FLAG_DETACHED; 607 thread->blocked = 0; 608 thread->errno = 0; 609 thread->fork_user = 0; // not inherited 610 thread->fork_cxy = 0; // not inherited 611 612 // reset thread info 613 memset( &thread->info , 0 , sizeof(thread_info_t) ); 614 615 // initialize join_lock 616 remote_spinlock_init( XPTR( local_cxy , &thread->join_lock ) ); 617 618 // allocate an user stack vseg for main thread 619 vseg_t * vseg = vmm_create_vseg( process, 620 VSEG_TYPE_STACK, 621 0, // size unused 622 0, // length unused 623 0, // file_offset unused 624 0, // file_size unused 625 XPTR_NULL, // mapper_xp unused 626 local_cxy ); 627 if( vseg == NULL ) 628 { 629 printk("\n[ERROR] in %s : cannot create stack vseg for main thread\n", __FUNCTION__ ); 630 return -1; 631 } 632 633 // update user stack in stack descriptor 634 thread->u_stack_base = vseg->min; 635 thread->u_stack_size = vseg->max - vseg->min; 636 637 // release FPU ownership if required 638 if( thread->core->fpu_owner == thread ) thread->core->fpu_owner = NULL; 639 640 // re-initialize FPU context 641 hal_fpu_context_init( thread ); 642 643 #if DEBUG_THREAD_USER_EXEC 644 cycle = (uint32_t)hal_get_cycles(); 645 if( DEBUG_THREAD_USER_EXEC < cycle ) 646 printk("\n[DBG] %s : thread %x in process %x set CPU context & jump to user code / cycle %d\n", 647 __FUNCTION__, thread->trdid, process->pid, cycle ); 648 vmm_display( process , true ); 649 #endif 650 651 // re-initialize CPU context... and jump to user code 652 hal_cpu_context_exec( thread ); 653 654 assert( false, __FUNCTION__, "we should execute this code"); 655 656 return 0; 657 658 } // end thread_user_exec() 659 556 660 ///////////////////////////////////////////////////////// 557 661 error_t thread_kernel_create( thread_t ** new_thread, … … 594 698 { 595 699 thread_release( thread ); 700 return ENOMEM; 701 } 702 703 // allocate & initialize CPU context 704 error = hal_cpu_context_alloc( thread ); 705 if( error ) 706 { 707 thread_release( thread ); 596 708 return EINVAL; 597 709 } 598 599 // allocate & initialize CPU context 600 hal_cpu_context_create( thread ); 710 hal_cpu_context_init( thread ); 711 601 712 602 713 #if DEBUG_THREAD_KERNEL_CREATE … … 612 723 } // end thread_kernel_create() 613 724 614 ////////////////////////////////////////////// ///615 error_tthread_idle_init( thread_t * thread,616 617 618 619 725 ////////////////////////////////////////////// 726 void thread_idle_init( thread_t * thread, 727 thread_type_t type, 728 void * func, 729 void * args, 730 lid_t core_lid ) 620 731 { 621 732 assert( (type == THREAD_IDLE) , __FUNCTION__ , "illegal thread type" ); 622 623 733 assert( (core_lid < LOCAL_CLUSTER->cores_nr) , __FUNCTION__ , "illegal core index" ); 624 734 735 // initialize thread descriptor 625 736 error_t error = thread_init( thread, 626 737 &process_zero, … … 631 742 0 , 0 ); // no user stack for a kernel thread 632 743 744 assert( (error == 0), __FUNCTION__, "cannot create thread idle" ); 745 633 746 // allocate & initialize CPU context if success 634 if( error == 0 ) hal_cpu_context_create( thread ); 635 636 return error; 747 error = hal_cpu_context_alloc( thread ); 748 749 assert( (error == 0), __FUNCTION__, "cannot allocate CPU context" ); 750 751 hal_cpu_context_init( thread ); 637 752 638 753 } // end thread_idle_init() … … 798 913 799 914 #if DEBUG_THREAD_BLOCK 800 uint32_t cycle = (uint32_t)hal_get_cycles(); 915 uint32_t cycle = (uint32_t)hal_get_cycles(); 916 process_t * process = hal_remote_lpt( XPTR( cxy , &ptr->process ) ); 801 917 if( DEBUG_THREAD_BLOCK < cycle ) 802 printk("\n[DBG] %s : thread %x in cxy %x blocked thread %x in cxy %x / cause %x / cycle %d\n", 803 __FUNCTION__ , CURRENT_THREAD , local_cxy , ptr , cxy , cause , cycle ); 918 printk("\n[DBG] %s : thread %x in process %x blocked thread %x in process %x / cause %x\n", 919 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, 920 ptr->trdid, hal_remote_lw(XPTR( cxy , &process->pid )), cause ); 804 921 #endif 805 922 … … 819 936 820 937 #if DEBUG_THREAD_BLOCK 821 uint32_t cycle = (uint32_t)hal_get_cycles(); 938 uint32_t cycle = (uint32_t)hal_get_cycles(); 939 process_t * process = hal_remote_lpt( XPTR( cxy , &ptr->process ) ); 822 940 if( DEBUG_THREAD_BLOCK < cycle ) 823 printk("\n[DBG] %s : thread %x in cxy %x unblocked thread %x in cxy %x / cause %x / cycle %d\n", 824 __FUNCTION__ , CURRENT_THREAD , local_cxy , ptr , cxy , cause , cycle ); 941 printk("\n[DBG] %s : thread %x in process %x unblocked thread %x in process %x / cause %x\n", 942 __FUNCTION__, CURRENT_THREAD->trdid, CURRENT_THREAD->process->pid, 943 ptr->trdid, hal_remote_lw(XPTR( cxy , &process->pid )), cause ); 825 944 #endif 826 945 -
trunk/kernel/kern/thread.h
r446 r457 26 26 #define _THREAD_H_ 27 27 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <shared_syscalls.h> 30 30 #include <hal_special.h> … … 161 161 void * entry_func; /*! pointer on entry function */ 162 162 void * entry_args; /*! pointer on entry function arguments */ 163 uint32_t main_argc; /*! main thread number of arguments */ 164 char ** main_argv; /*! main thread array of strings arguments */ 163 165 164 166 uint32_t flags; /*! bit vector of flags */ … … 218 220 * The CPU context is initialized from scratch. 219 221 * It is registered in the local process descriptor specified by the <pid> argument. 220 * The THREAD_BLOCKED_GLOBAL bit is set => the thread must be activated to start. 222 * The THREAD_BLOCKED_GLOBAL bit is set => the thread must be activated by the caller 223 * to start at the next scheduling point. 221 224 *************************************************************************************** 222 225 * @ pid : process identifier. … … 258 261 259 262 /*************************************************************************************** 263 * This function is called by the process_make_exec() function to re-initialise the 264 * thread descriptor of the calling thread (that will become the new process main 265 * thread), and immediately jump to user code without returning to kentry!!! 266 * It must be called by the main thread of the calling process. 267 * - A new user stack vseg is created and initialised. 268 * - The kernel stack (currently in use) is not modified. 269 * - The function calls the hal_cpu_context_exec() to re-initialize the CPU context 270 * an jump to user code. 271 *************************************************************************************** 272 * @ entry_func : main thread entry point. 273 * @ argc : number of main thread arguments. 274 * @ argv : array of pointers on stringarguments. 275 * @ returns 0 if success / returns ENOMEM if error. 276 **************************************************************************************/ 277 error_t thread_user_exec( void * entry_func, 278 uint32_t argc, 279 char ** argv); 280 281 /*************************************************************************************** 260 282 * This function allocates memory for a kernel thread descriptor in the local cluster, 261 283 * and initializes it from arguments values. … … 281 303 * descriptor from arguments values. 282 304 * The THREAD_BLOCKED_GLOBAL bit is set, and the thread must be activated to start. 305 * It returns a kernel panic if failure. 283 306 *************************************************************************************** 284 307 * @ thread : pointer on existing thread descriptor. … … 287 310 * @ args : function arguments. 288 311 * @ core_lid : local core index. 289 * @ returns 0 if success / returns EINVAL if error 290 **************************************************************************************/ 291 error_t thread_idle_init( thread_t * thread, 292 thread_type_t type, 293 void * func, 294 void * args, 295 lid_t core_lid ); 312 **************************************************************************************/ 313 void thread_idle_init( thread_t * thread, 314 thread_type_t type, 315 void * func, 316 void * args, 317 lid_t core_lid ); 296 318 297 319 /*************************************************************************************** -
trunk/kernel/kernel_config.h
r450 r457 27 27 #define _ALMOS_CONFIG_H_ 28 28 29 #define CONFIG_ALMOS_VERSION "Version 1.0 / March2018"29 #define CONFIG_ALMOS_VERSION "Version 1.0 / August 2018" 30 30 31 31 //////////////////////////////////////////////////////////////////////////////////////////// … … 76 76 #define DEBUG_HAL_IOC_RX 0 77 77 #define DEBUG_HAL_IOC_TX 0 78 #define DEBUG_HAL_GPT 78 #define DEBUG_HAL_GPT 0 79 79 80 80 #define DEBUG_KCM 0 … … 117 117 118 118 #define DEBUG_SCHED_HANDLE_SIGNALS 2 119 #define DEBUG_SCHED_YIELD 2// must be activated by the trace() syscall119 #define DEBUG_SCHED_YIELD 1 // must be activated by the trace() syscall 120 120 121 121 #define DEBUG_SYSCALLS_ERROR 2 122 122 123 123 #define DEBUG_SYS_DISPLAY 0 124 #define DEBUG_SYS_EXEC 1125 #define DEBUG_SYS_EXIT 1124 #define DEBUG_SYS_EXEC 0 125 #define DEBUG_SYS_EXIT 0 126 126 #define DEBUG_SYS_FG 0 127 127 #define DEBUG_SYS_FORK 0 128 128 #define DEBUG_SYS_GET_CONFIG 0 129 129 #define DEBUG_SYS_ISATTY 0 130 #define DEBUG_SYS_IS_FG 0 130 131 #define DEBUG_SYS_KILL 0 131 132 #define DEBUG_SYS_MMAP 0 … … 154 155 #define DEBUG_THREAD_USER_CREATE 0 155 156 #define DEBUG_THREAD_USER_FORK 0 157 #define DEBUG_THREAD_USER_EXEC 0 156 158 #define DEBUG_THREAD_BLOCK 0 157 159 -
trunk/kernel/libk/barrier.c
r16 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_remote.h> 26 26 #include <hal_atomic.h> -
trunk/kernel/libk/barrier.h
r423 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 30 30 /***************************************************************************************** -
trunk/kernel/libk/bits.c
r351 r457 23 23 */ 24 24 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <bits.h> 27 27 -
trunk/kernel/libk/bits.h
r454 r457 27 27 28 28 #include <kernel_config.h> 29 #include <hal_ types.h>29 #include <hal_kernel_types.h> 30 30 31 31 /********************************************************************************************* -
trunk/kernel/libk/ctype.c
r1 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 26 26 //////////////////// -
trunk/kernel/libk/elf.c
r441 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_special.h> 27 27 #include <hal_uspace.h> … … 210 210 } // end elf_segments_register() 211 211 212 ////////////////////////////////////////////// /213 error_t elf_load_process( char * pathname,214 process_t * process )212 ////////////////////////////////////////////// 213 error_t elf_load_process( xptr_t file_xp, 214 process_t * process ) 215 215 { 216 216 kmem_req_t req; // kmem request for program header … … 218 218 void * segs_base; // pointer on buffer for segment descriptors array 219 219 uint32_t segs_size; // size of buffer for segment descriptors array 220 xptr_t file_xp; // extended pointer on created file descriptor 221 uint32_t file_id; // file descriptor index (unused) 220 char name[CONFIG_VFS_MAX_NAME_LENGTH]; 222 221 error_t error; 223 222 223 // get file name for error reporting and debug 224 cxy_t file_cxy = GET_CXY( file_xp ); 225 vfs_file_t * file_ptr = GET_PTR( file_xp ); 226 vfs_inode_t * inode = hal_remote_lpt( XPTR( file_cxy , &file_ptr->inode ) ); 227 vfs_inode_get_name( XPTR( file_cxy , inode ) , name ); 228 224 229 #if DEBUG_ELF_LOAD 225 uint32_t cycle = (uint32_t)hal_get_cycles(); 226 if( DEBUG_ELF_LOAD < cycle ) 227 printk("\n[DBG] %s : thread %d enter for <%s> / cycle %d\n", 228 __FUNCTION__, CURRENT_THREAD, pathname, cycle ); 229 #endif 230 231 // avoid GCC warning 232 file_xp = XPTR_NULL; 233 file_id = -1; 234 235 // open file 236 error = vfs_open( process, 237 pathname, 238 O_RDONLY, 239 0, 240 &file_xp, 241 &file_id ); 242 if( error ) 243 { 244 printk("\n[ERROR] in %s : failed to open file <%s>\n", __FUNCTION__ , pathname ); 245 return -1; 246 } 247 248 #if (DEBUG_ELF_LOAD & 1) 249 if( DEBUG_ELF_LOAD < cycle ) 250 printk("\n[DBG] %s : open file <%s>\n", __FUNCTION__, pathname ); 230 uint32_t cycle = (uint32_t)hal_get_cycles(); 231 if( DEBUG_ELF_LOAD < cycle ) 232 printk("\n[DBG] %s : thread %d in process %x enter for <%s> / cycle %d\n", 233 __FUNCTION__, CURRENT_THREAD->trdid, process->pid, name, cycle ); 251 234 #endif 252 235 … … 257 240 if( error ) 258 241 { 259 printk("\n[ERROR] in %s : cannot get header for <%s>\n", __FUNCTION__ , pathname ); 260 vfs_close( file_xp , file_id ); 242 printk("\n[ERROR] in %s : cannot get header for <%s>\n", __FUNCTION__ , name ); 261 243 return -1; 262 244 } … … 264 246 #if (DEBUG_ELF_LOAD & 1) 265 247 if( DEBUG_ELF_LOAD < cycle ) 266 printk("\n[DBG] %s : loaded elf header for <%s>\n", __FUNCTION__ , pathname );248 printk("\n[DBG] %s : loaded elf header for <%s>\n", __FUNCTION__ , name ); 267 249 #endif 268 250 … … 270 252 { 271 253 printk("\n[ERROR] in %s : no segments found\n", __FUNCTION__ ); 272 vfs_close( file_xp , file_id );273 254 return -1; 274 255 } … … 286 267 { 287 268 printk("\n[ERROR] in %s : no memory for segment descriptors\n", __FUNCTION__ ); 288 vfs_close( file_xp , file_id );289 269 return -1; 290 270 } … … 296 276 { 297 277 printk("\n[ERROR] in %s : cannot seek for descriptors array\n", __FUNCTION__ ); 298 vfs_close( file_xp , file_id );299 278 req.ptr = segs_base; 300 279 kmem_free( &req ); … … 304 283 #if (DEBUG_ELF_LOAD & 1) 305 284 if( DEBUG_ELF_LOAD < cycle ) 306 printk("\n[DBG] %s : segments array allocated for <%s>\n", __FUNCTION__ , pathname );285 printk("\n[DBG] %s : segments array allocated for <%s>\n", __FUNCTION__ , name ); 307 286 #endif 308 287 … … 316 295 { 317 296 printk("\n[ERROR] in %s : cannot read segments descriptors\n", __FUNCTION__ ); 318 vfs_close( file_xp , file_id );319 297 req.ptr = segs_base; 320 298 kmem_free( &req ); … … 324 302 #if (DEBUG_ELF_LOAD & 1) 325 303 if( DEBUG_ELF_LOAD < cycle ) 326 printk("\n[DBG] %s loaded segments descriptors for <%s>\n", __FUNCTION__ , pathname );304 printk("\n[DBG] %s loaded segments descriptors for <%s>\n", __FUNCTION__ , name ); 327 305 #endif 328 306 … … 334 312 if( error ) 335 313 { 336 vfs_close( file_xp , file_id );337 314 req.ptr = segs_base; 338 315 kmem_free( &req ); … … 353 330 cycle = (uint32_t)hal_get_cycles(); 354 331 if( DEBUG_ELF_LOAD < cycle ) 355 printk("\n[DBG] %s : thread % dexit for <%s> / entry_point %x / cycle %d\n",356 __FUNCTION__, CURRENT_THREAD , pathname, header.e_entry, cycle );332 printk("\n[DBG] %s : thread %x in process %x exit for <%s> / entry_point %x / cycle %d\n", 333 __FUNCTION__, CURRENT_THREAD->trdid, process->pid, name, header.e_entry, cycle ); 357 334 #endif 358 335 -
trunk/kernel/libk/elf.h
r273 r457 22 22 #define _ELF_H_ 1 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 26 26 /* … … 204 204 #define PF_MASKPROC 0xf0000000 /* Processor-specific */ 205 205 206 #if defined(HAL_ 32BIT)206 #if defined(HAL_ELF_32_BITS) 207 207 #define Elf_Half Elf32_Half 208 208 #define Elf_Word Elf32_Word … … 213 213 #define Elf_Phdr Elf32_Phdr 214 214 #define ELFCLASS ELFCLASS32 215 #elif defined (HAL_ 64BIT)215 #elif defined (HAL_ELF_64_BITS) 216 216 #define Elf_Half Elf64_Half 217 217 #define Elf_Word Elf64_Word … … 224 224 #define ELFCLASS ELFCLASS64 225 225 #else 226 #error "Must define HAL_ 64BIT/HAL_32BIT"226 #error "Must define HAL_ELF_64_BITS / HAL_ELF_32_BITS" 227 227 #endif 228 228 229 229 /**************************************************************************************** 230 * This function registers in VMM the CODE and DATA vsegs defined in the .elf file. 230 * This function registers in VMM of the process identified by the <process> argument 231 * the CODE and DATA vsegs defined in the .elf open file descriptor <file_xp>. 231 232 * The segments are not loaded in memory. 232 233 * It also registers the process entry point in VMM. 233 234 **************************************************************************************** 234 * @ pathname : local pointer on .elf file pathname (in kernel space).235 * @ file_xp : extended pointer on .elf file descriptor. 235 236 * @ process : local pointer on target process descriptor. 236 237 ***************************************************************************************/ 237 error_t elf_load_process( char * pathname,238 error_t elf_load_process( xptr_t file_xp, 238 239 process_t * process); 239 240 -
trunk/kernel/libk/grdxt.c
r423 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_special.h> 26 26 #include <errno.h> -
trunk/kernel/libk/grdxt.h
r406 r457 25 25 #define _GRDXT_H_ 26 26 27 #include <hal_ types.h>27 #include <hal_kernel_types.h> 28 28 29 29 /******************************************************************************************* -
trunk/kernel/libk/htab.c
r423 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_special.h> 27 27 #include <htab.h> -
trunk/kernel/libk/htab.h
r23 r457 26 26 #define _HTAB_H_ 27 27 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <rwlock.h> 30 30 #include <list.h> -
trunk/kernel/libk/list.h
r450 r457 27 27 28 28 #include <kernel_config.h> 29 #include <hal_ types.h>29 #include <hal_kernel_types.h> 30 30 31 31 #ifndef NULL -
trunk/kernel/libk/memcpy.c
r113 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <printk.h> 26 26 -
trunk/kernel/libk/memcpy.h
r113 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 26 26 -
trunk/kernel/libk/readlock.c
r124 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_atomic.h> 27 27 #include <hal_special.h> -
trunk/kernel/libk/readlock.h
r14 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 30 30 /******************************************************************************************* -
trunk/kernel/libk/remote_barrier.c
r436 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_remote.h> 26 26 #include <hal_irqmask.h> -
trunk/kernel/libk/remote_barrier.h
r23 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <remote_spinlock.h> 30 30 #include <xlist.h> -
trunk/kernel/libk/remote_condvar.c
r436 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_remote.h> 26 26 #include <hal_irqmask.h> -
trunk/kernel/libk/remote_condvar.h
r23 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <remote_spinlock.h> 30 30 #include <xlist.h> -
trunk/kernel/libk/remote_fifo.c
r408 r457 23 23 */ 24 24 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_irqmask.h> 27 27 #include <hal_remote.h> -
trunk/kernel/libk/remote_fifo.h
r407 r457 27 27 28 28 #include <kernel_config.h> 29 #include <hal_ types.h>29 #include <hal_kernel_types.h> 30 30 #include <printk.h> 31 31 #include <errno.h> -
trunk/kernel/libk/remote_mutex.c
r436 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_remote.h> 26 26 #include <hal_special.h> -
trunk/kernel/libk/remote_mutex.h
r23 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <xlist.h> 30 30 -
trunk/kernel/libk/remote_rwlock.c
r438 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_remote.h> 26 26 #include <hal_irqmask.h> -
trunk/kernel/libk/remote_rwlock.h
r438 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <xlist.h> 30 30 -
trunk/kernel/libk/remote_sem.c
r436 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_remote.h> 26 26 #include <thread.h> … … 75 75 76 76 /////////////////////////////////////////// 77 error_t remote_sem_create( intptr_t vaddr, 78 uint32_t value ) 79 { 77 error_t remote_sem_create( intptr_t vaddr, 78 uint32_t value, 79 xptr_t sem_xp_xp ) 80 { 81 remote_sem_t * sem_ptr; 80 82 xptr_t sem_xp; 81 remote_sem_t * sem_ptr;82 83 83 84 // get pointer on local process descriptor … … 103 104 { 104 105 rpc_kcm_alloc_client( ref_cxy , KMEM_SEM , &sem_xp ); 105 sem_ptr = (remote_sem_t *)GET_PTR( sem_xp );106 } 107 108 if( sem_xp == XPTR_NULL ) return ENOMEM;106 sem_ptr = GET_PTR( sem_xp ); 107 } 108 109 if( sem_xp == XPTR_NULL ) return -1; 109 110 110 111 // initialise semaphore 111 112 hal_remote_sw ( XPTR( ref_cxy , &sem_ptr->count ) , value ); 112 113 hal_remote_spt( XPTR( ref_cxy , &sem_ptr->ident ) , (void *)vaddr ); 113 114 114 remote_spinlock_init( XPTR( ref_cxy , &sem_ptr->lock ) ); 115 115 xlist_root_init( XPTR( ref_cxy , &sem_ptr->root ) ); … … 119 119 xptr_t root_xp = XPTR( ref_cxy , &ref_ptr->sem_root ); 120 120 xptr_t xp_list = XPTR( ref_cxy , &sem_ptr->list ); 121 122 121 remote_spinlock_lock( XPTR( ref_cxy , &ref_ptr->sync_lock ) ); 123 122 xlist_add_first( root_xp , xp_list ); 124 123 remote_spinlock_unlock( XPTR( ref_cxy , &ref_ptr->sync_lock ) ); 125 124 125 // write extended pointer on semaphore in calling thread buffer 126 hal_remote_swd( sem_xp_xp , sem_xp ); 127 126 128 return 0; 127 129 128 } // en remote_sem_ init()130 } // en remote_sem_create() 129 131 130 132 //////////////////////////////////////// … … 139 141 // get reference process cluster and local pointer 140 142 cxy_t ref_cxy = GET_CXY( ref_xp ); 141 process_t * ref_ptr = (process_t *)GET_PTR( ref_xp );143 process_t * ref_ptr = GET_PTR( ref_xp ); 142 144 143 145 // get semaphore cluster and local pointer … … 148 150 remote_spinlock_lock( XPTR( sem_cxy , &sem_ptr->lock ) ); 149 151 150 // get remote pointer on waiting queue 151 xptr_t root_xp = (xptr_t)hal_remote_lwd( XPTR( sem_cxy , &sem_ptr->root ));152 // get remote pointer on waiting queue root 153 xptr_t root_xp = XPTR( sem_cxy , &sem_ptr->root ); 152 154 153 155 if( !xlist_is_empty( root_xp ) ) // user error … … 184 186 } // end remote_sem_destroy() 185 187 186 ////////////////////////////////// 188 ///////////////////////////////////// 187 189 void remote_sem_wait( xptr_t sem_xp ) 188 190 { 189 191 // get semaphore cluster and local pointer 190 192 cxy_t sem_cxy = GET_CXY( sem_xp ); 191 remote_sem_t * sem_ptr = (remote_sem_t *)GET_PTR( sem_xp );193 remote_sem_t * sem_ptr = GET_PTR( sem_xp ); 192 194 193 195 // get lock protecting semaphore … … 210 212 211 213 // register thread in waiting queue 212 xptr_t root_xp = (xptr_t)hal_remote_lwd( XPTR( sem_cxy , &sem_ptr->root ));213 xptr_t thread_xp = XPTR( local_cxy , this);214 xlist_add_last( root_xp , thread_xp );214 xptr_t root_xp = XPTR( sem_cxy , &sem_ptr->root ); 215 xptr_t list_xp = XPTR( local_cxy , &this->wait_list ); 216 xlist_add_last( root_xp , list_xp ); 215 217 216 218 // release lock … … 228 230 // get semaphore cluster and local pointer 229 231 cxy_t sem_cxy = GET_CXY( sem_xp ); 230 remote_sem_t * sem_ptr = (remote_sem_t *)GET_PTR( sem_xp );232 remote_sem_t * sem_ptr = GET_PTR( sem_xp ); 231 233 232 234 // get lock protecting semaphore 233 235 remote_spinlock_lock( XPTR( sem_cxy , &sem_ptr->lock ) ); 234 236 237 // get semaphore current value 238 uint32_t count = hal_remote_lw( XPTR( sem_cxy , &sem_ptr->count ) ); 239 235 240 // get remote pointer on waiting queue root 236 xptr_t root_xp = (xptr_t)hal_remote_lwd( XPTR( sem_cxy , &sem_ptr->root ));241 xptr_t root_xp = XPTR( sem_cxy , &sem_ptr->root ); 237 242 238 243 if( xlist_is_empty( root_xp ) ) // no waiting thread 239 244 { 240 // get semaphore current value241 uint32_t count = hal_remote_lw( XPTR( sem_cxy , &sem_ptr->count ) );242 243 245 // increment semaphore value 244 246 hal_remote_sw( XPTR( sem_cxy , &sem_ptr->count ) , count + 1 ); … … 251 253 // get thread cluster and local poiner 252 254 cxy_t thread_cxy = GET_CXY( thread_xp ); 253 thread_t * thread_ptr = (thread_t *)GET_PTR( thread_xp );254 255 // remove th e thread from the waiting queue, and unblock255 thread_t * thread_ptr = GET_PTR( thread_xp ); 256 257 // remove this thread from the waiting queue, and unblock it 256 258 xlist_unlink( XPTR( thread_cxy , &thread_ptr->wait_list ) ); 257 259 thread_unblock( thread_xp , THREAD_BLOCKED_SEM ); … … 270 272 // get semaphore cluster and local pointer 271 273 cxy_t sem_cxy = GET_CXY( sem_xp ); 272 remote_sem_t * sem_ptr = (remote_sem_t *)GET_PTR( sem_xp );274 remote_sem_t * sem_ptr = GET_PTR( sem_xp ); 273 275 274 276 *data = hal_remote_lw( XPTR( sem_cxy , &sem_ptr->count ) ); -
trunk/kernel/libk/remote_sem.h
r23 r457 25 25 #define _SEMAPHORE_H_ 26 26 27 #include <hal_ types.h>27 #include <hal_kernel_types.h> 28 28 #include <xlist.h> 29 29 #include <remote_spinlock.h> … … 77 77 * This function implements the SEM_INIT operation. 78 78 * It allocates memory for a remote semaphore in reference cluster, using a RPC if required, 79 * and initializes it, using remote accesses. 79 * and initializes it, using remote accesses from values defined by the <vaddr> and <value> 80 * arguments. It uses also a remote access to return the extended pointer on the semaphore 81 * in the buffer identified by the <buf_xp> argument. 80 82 ********************************************************************************************* 81 * @ vaddr : semaphore virtual address, used as identifier. 82 * @ value : semaphore initial value. 83 * @ returns 0 if success / returns ENOMEM if error. 83 * @ vaddr : [in] semaphore virtual address, used as identifier. 84 * @ value : [in] semaphore initial value. 85 * @ sem_xp_xp : [out] extended pointer on buffer to store extended pointer on semaphore. 86 * @ returns 0 if success / returns -1 if no memory. 84 87 ********************************************************************************************/ 85 88 error_t remote_sem_create( intptr_t vaddr, 86 uint32_t value ); 89 uint32_t value, 90 xptr_t sem_xp_xp ); 87 91 88 92 /****************************yy*************************************************************** … … 91 95 * reference cluster, using a RPC if required. 92 96 ********************************************************************************************* 93 * @ sem_xp : extended pointer on semaphore.97 * @ sem_xp : [in] extended pointer on semaphore. 94 98 ********************************************************************************************/ 95 99 void remote_sem_destroy( xptr_t sem_xp ); … … 102 106 * waiting queue, block the thread, and yield. 103 107 ********************************************************************************************* 104 * @ sem_xp : extended pointer on semaphore.108 * @ sem_xp : [in] extended pointer on semaphore. 105 109 ********************************************************************************************/ 106 110 void remote_sem_wait( xptr_t sem_xp ); … … 111 115 * - If the waiting queue is not empty, it wakes up the first waiting thread. 112 116 ********************************************************************************************* 113 * @ sem_xp : extended pointer on semaphore.117 * @ sem_xp : [in] extended pointer on semaphore. 114 118 ********************************************************************************************/ 115 119 void remote_sem_post( xptr_t sem_xp ); … … 119 123 * It returns in the <data> buffer the semaphore current value. 120 124 ********************************************************************************************* 121 * @ sem_xp : extended pointer on semaphore.122 * @ data : [out] returned value.125 * @ sem_xp : [in] extended pointer on semaphore. 126 * @ data : [out] local pointer on buffer for returned value. 123 127 ********************************************************************************************/ 124 128 void remote_sem_get_value( xptr_t sem_xp, -
trunk/kernel/libk/remote_spinlock.c
r443 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_remote.h> 26 26 #include <hal_irqmask.h> -
trunk/kernel/libk/remote_spinlock.h
r438 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <xlist.h> 30 30 -
trunk/kernel/libk/rwlock.c
r438 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_atomic.h> 27 27 #include <hal_special.h> -
trunk/kernel/libk/rwlock.h
r438 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <list.h> 30 30 -
trunk/kernel/libk/spinlock.c
r438 r457 24 24 25 25 #include <kernel_config.h> 26 #include <hal_ types.h>26 #include <hal_kernel_types.h> 27 27 #include <hal_atomic.h> 28 28 #include <hal_special.h> -
trunk/kernel/libk/spinlock.h
r438 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <list.h> 30 30 -
trunk/kernel/libk/string.c
r337 r457 23 23 */ 24 24 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <ctype.h> 27 27 #include <string.h> -
trunk/kernel/libk/string.h
r323 r457 26 26 #define _STRING_H_ 27 27 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 30 30 -
trunk/kernel/libk/xhtab.c
r423 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_special.h> 27 27 #include <hal_remote.h> -
trunk/kernel/libk/xhtab.h
r204 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <remote_rwlock.h> 30 30 #include <xlist.h> -
trunk/kernel/libk/xlist.h
r435 r457 26 26 27 27 #include <kernel_config.h> 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <hal_remote.h> 30 30 -
trunk/kernel/mm/kcm.c
r438 r457 24 24 25 25 #include <kernel_config.h> 26 #include <hal_ types.h>26 #include <hal_kernel_types.h> 27 27 #include <hal_special.h> 28 28 #include <list.h> -
trunk/kernel/mm/kcm.h
r437 r457 27 27 28 28 #include <list.h> 29 #include <hal_ types.h>29 #include <hal_kernel_types.h> 30 30 #include <spinlock.h> 31 31 #include <page.h> -
trunk/kernel/mm/khm.c
r315 r457 24 24 25 25 #include <kernel_config.h> 26 #include <hal_ types.h>26 #include <hal_kernel_types.h> 27 27 #include <hal_special.h> 28 28 #include <spinlock.h> -
trunk/kernel/mm/khm.h
r18 r457 28 28 29 29 #include <kernel_config.h> 30 #include <hal_ types.h>30 #include <hal_kernel_types.h> 31 31 #include <spinlock.h> 32 32 -
trunk/kernel/mm/kmem.c
r438 r457 25 25 26 26 #include <kernel_config.h> 27 #include <hal_ types.h>27 #include <hal_kernel_types.h> 28 28 #include <hal_special.h> 29 29 #include <printk.h> -
trunk/kernel/mm/kmem.h
r188 r457 27 27 #define _KMEM_H_ 28 28 29 #include <hal_ types.h>29 #include <hal_kernel_types.h> 30 30 #include <kcm.h> 31 31 -
trunk/kernel/mm/mapper.c
r440 r457 24 24 25 25 #include <kernel_config.h> 26 #include <hal_ types.h>26 #include <hal_kernel_types.h> 27 27 #include <hal_special.h> 28 28 #include <hal_uspace.h> -
trunk/kernel/mm/mapper.h
r440 r457 26 26 #define _MAPPER_H_ 27 27 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <hal_atomic.h> 30 30 #include <xlist.h> -
trunk/kernel/mm/page.c
r436 r457 23 23 */ 24 24 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_special.h> 27 27 #include <hal_atomic.h> -
trunk/kernel/mm/page.h
r433 r457 27 27 28 28 #include <kernel_config.h> 29 #include <hal_ types.h>29 #include <hal_kernel_types.h> 30 30 #include <spinlock.h> 31 31 #include <list.h> -
trunk/kernel/mm/ppm.c
r438 r457 24 24 25 25 #include <kernel_config.h> 26 #include <hal_ types.h>26 #include <hal_kernel_types.h> 27 27 #include <hal_special.h> 28 28 #include <printk.h> -
trunk/kernel/mm/ppm.h
r433 r457 26 26 #define _PPM_H_ 27 27 28 #include <hal_ types.h>28 #include <hal_kernel_types.h> 29 29 #include <list.h> 30 30 #include <spinlock.h> -
trunk/kernel/mm/vmm.c
r443 r457 25 25 26 26 #include <kernel_config.h> 27 #include <hal_ types.h>27 #include <hal_kernel_types.h> 28 28 #include <hal_special.h> 29 29 #include <hal_gpt.h> … … 170 170 vmm->stack_mgr.bitmap = 0; 171 171 vmm->stack_mgr.vpn_base = CONFIG_VMM_STACK_BASE; 172 spinlock_init( &vmm->stack_mgr.lock ); 172 173 173 174 // initialize MMAP allocator … … 175 176 vmm->mmap_mgr.vpn_size = CONFIG_VMM_STACK_BASE - CONFIG_VMM_HEAP_BASE; 176 177 vmm->mmap_mgr.first_free_vpn = CONFIG_VMM_HEAP_BASE; 178 spinlock_init( &vmm->mmap_mgr.lock ); 179 177 180 uint32_t i; 178 181 for( i = 0 ; i < 32 ; i++ ) list_root_init( &vmm->mmap_mgr.zombi_list[i] ); … … 201 204 gpt_t * gpt = &vmm->gpt; 202 205 203 printk("\n***** VSL and GPT for process %x in cluster %x\n\n", process->pid , local_cxy ); 206 printk("\n***** VSL and GPT(%x) for process %x in cluster %x\n\n", 207 process->vmm.gpt.ptr , process->pid , local_cxy ); 204 208 205 209 // get lock protecting the vseg list -
trunk/kernel/mm/vmm.h
r440 r457 27 27 #define _VMM_H_ 28 28 29 #include <hal_ types.h>29 #include <hal_kernel_types.h> 30 30 #include <bits.h> 31 31 #include <list.h> -
trunk/kernel/mm/vseg.c
r453 r457 24 24 */ 25 25 26 #include <hal_ types.h>26 #include <hal_kernel_types.h> 27 27 #include <hal_special.h> 28 28 #include <hal_remote.h> … … 171 171 switch (vseg->type) 172 172 { 173 case VSEG_TYPE_DATA: { 173 case VSEG_TYPE_DATA: 174 { 174 175 vseg->cxy = 0xffff; 175 176 break; 176 177 } 177 178 case VSEG_TYPE_CODE: 178 case VSEG_TYPE_STACK: { 179 case VSEG_TYPE_STACK: 180 { 179 181 vseg->cxy = local_cxy; 180 182 break; … … 182 184 case VSEG_TYPE_ANON: 183 185 case VSEG_TYPE_FILE: 184 case VSEG_TYPE_REMOTE: { 186 case VSEG_TYPE_REMOTE: 187 { 185 188 vseg->cxy = (cxy_t) hal_remote_lw( XPTR(cxy, &ptr->cxy) ); 186 189 break; 187 190 } 188 default: { 191 default: 192 { 189 193 assert( false, __FUNCTION__, "Illegal vseg type" ); 190 194 break; -
trunk/kernel/mm/vseg.h
r454 r457 27 27 #define _VSEG_H_ 28 28 29 #include <hal_ types.h>29 #include <hal_kernel_types.h> 30 30 #include <spinlock.h> 31 31 #include <vfs.h> -
trunk/kernel/syscalls/shared_include/shared_pthread.h
r445 r457 29 29 ******************************************************************************************/ 30 30 31 typedef unsigned int sem_t;32 31 typedef unsigned int pthread_cond_t; 33 32 typedef unsigned int pthread_condattr_t; … … 56 55 PT_ATTR_CORE_DEFINED = 0x0004, /*! user defined core index in cluster */ 57 56 }; 58 59 /*******************************************************************************************60 * This enum defines the operation mnemonics for operations on POSIX unnamed semaphores.61 ******************************************************************************************/62 63 typedef enum64 {65 SEM_INIT,66 SEM_DESTROY,67 SEM_GETVALUE,68 SEM_WAIT,69 SEM_POST,70 }71 sem_operation_t;72 57 73 58 /******************************************************************************************* -
trunk/kernel/syscalls/shared_include/syscalls_numbers.h
r444 r457 62 62 SYS_TRACE = 47, 63 63 SYS_FG = 48, 64 SYS_ UNDEFINED_49 = 49, ///64 SYS_IS_FG = 49, 65 65 66 66 SYSCALLS_NR = 50, -
trunk/kernel/syscalls/sys_alarm.c
r23 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <thread.h> 26 26 #include <printk.h> -
trunk/kernel/syscalls/sys_barrier.c
r440 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_special.h> 26 26 #include <errno.h> -
trunk/kernel/syscalls/sys_chdir.c
r407 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_uspace.h> 26 26 #include <chdev.h> -
trunk/kernel/syscalls/sys_chmod.c
r407 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_uspace.h> 26 26 #include <vfs.h> -
trunk/kernel/syscalls/sys_close.c
r124 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_special.h> 27 27 #include <vfs.h> -
trunk/kernel/syscalls/sys_closedir.c
r407 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <vfs.h> 26 26 #include <printk.h> -
trunk/kernel/syscalls/sys_condvar.c
r440 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_special.h> 26 26 #include <errno.h> -
trunk/kernel/syscalls/sys_creat.c
r407 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <vfs.h> 26 26 #include <syscalls.h> -
trunk/kernel/syscalls/sys_display.c
r450 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_uspace.h> 26 26 #include <errno.h> -
trunk/kernel/syscalls/sys_exec.c
r441 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_uspace.h> 27 27 #include <errno.h> … … 152 152 // It build an exec_info_t structure containing all informations 153 153 // required to initialize the new process descriptor and the associated thread. 154 // It includes the process main() arguments, the environment variables,154 // It includes the new process main() arguments, the environment variables, 155 155 // and the pathname to the new process .elf file. 156 156 // It calls the process_exec_get_strings() functions to copy the main() arguments and 157 157 // the environment variables from user buffers to the exec_info_t structure, allocate 158 158 // and call the process_make_exec() function. 159 // As it must destroy all parent process copies, and all parent threads in all clusters, 160 // the process_make_exec() function must be executed in the parent owner cluster, 161 // and this sys_exec() function uses a RPC to access the owner cluster if required. 159 // As it must destroy all process copies, and all othert threads in all clusters, 160 // the process_make_exec() function must be executed in the owner cluster. 162 161 // 163 162 // TODO : the args & envs arguments are not supported yet : both must be NULL [AG] … … 187 186 "args not supported yet\n" ); 188 187 189 // get owner cluster190 191 188 // check pathname length 192 189 if( hal_strlen_from_uspace( pathname ) >= CONFIG_VFS_MAX_PATH_LENGTH ) … … 205 202 #if DEBUG_SYS_EXEC 206 203 uint64_t tm_start; 207 uint64_t tm_end;208 204 tm_start = hal_get_cycles(); 209 205 if( DEBUG_SYS_EXEC < tm_start ) 210 206 printk("\n[DBG] %s : thread %x in process %x enter for path <%s> / cycle = %d\n", 211 __FUNCTION__, this , pid, exec_info.path, (uint32_t)tm_start );207 __FUNCTION__, this->trdid, pid, exec_info.path, (uint32_t)tm_start ); 212 208 #endif 213 209 … … 220 216 #if DEBUG_SYSCALLS_ERROR 221 217 printk("\n[ERROR] in %s : thread %x in process %x cannot access args\n", 222 __FUNCTION__ , this , pid );218 __FUNCTION__ , this->trdid, pid ); 223 219 #endif 224 220 this->errno = EINVAL; … … 235 231 #if DEBUG_SYCALLS_ERROR 236 232 printk("\n[ERROR] in %s : thread %x in process %x cannot access envs\n", 237 __FUNCTION__ , this , pid );233 __FUNCTION__ , this->trdid, pid ); 238 234 #endif 239 235 this->errno = EINVAL; … … 250 246 #if DEBUG_SYSCALLS_ERROR 251 247 printk("\n[ERROR] in %s : thread %x in process %x cannot create process for <%s>\n", 252 __FUNCTION__, this , pid, exec_info.path );248 __FUNCTION__, this->trdid, pid, exec_info.path ); 253 249 #endif 254 250 this->errno = error; … … 256 252 } 257 253 258 #if DEBUG_SYS_EXEC 259 tm_end = hal_get_cycles(); 260 if( DEBUG_SYS_EXEC < tm_end ) 261 printk("\n[DBG] %s : thread %x in process %x exit / cost = %d / cycle %d\n", 262 __FUNCTION__, this, pid, (uint32_t)(tm_end - tm_start), (uint32_t)tm_end ); 263 #endif 264 265 // In case of success, this calling thread deschedules, causing suicide, 266 // because a new process descriptor and its associated main thread 267 // have been created by the process_make_exec() function, and the 268 // BLOCKED_GLOBAL & FLAG_REQ_DELETE bits have been set for the calling thread. 269 sched_yield( "old process suicide in sys_exec()" ); 254 assert( false , __FUNCTION__, "we should not execute this code" ); 270 255 271 256 return 0; -
trunk/kernel/syscalls/sys_exit.c
r446 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_irqmask.h> 27 27 #include <errno.h> … … 59 59 tm_start = hal_get_cycles(); 60 60 if( DEBUG_SYS_EXIT < tm_start ) 61 printk("\n[DBG] %s : thread %x enter / process %x/ status %x / cycle %d\n",62 __FUNCTION__ , this,pid , status , (uint32_t)tm_start );61 printk("\n[DBG] %s : thread %x in process %x enter / status %x / cycle %d\n", 62 __FUNCTION__, this->trdid, process->pid , status , (uint32_t)tm_start ); 63 63 #endif 64 64 … … 70 70 #if (DEBUG_SYS_EXIT & 1) 71 71 if( DEBUG_SYS_EXIT < tm_start ) 72 printk("\n[DBG] %s : thread %x get owner process %x in cluster %x\n",73 __FUNCTION__ , this, owner_ptr, owner_cxy );72 printk("\n[DBG] %s : thread %x in process %x get owner process %x in cluster %x\n", 73 __FUNCTION__, this->trdid, process->pid, owner_ptr, owner_cxy ); 74 74 #endif 75 75 76 // get pointer on the process main thread76 // get local pointer on the process main thread 77 77 main_ptr = hal_remote_lpt( XPTR( owner_cxy , &owner_ptr->th_tbl[0] ) ); 78 78 … … 84 84 #if (DEBUG_SYS_EXIT & 1) 85 85 if( DEBUG_SYS_EXIT < tm_start ) 86 printk("\n[DBG] %s : thread %x get parent process %x in cluster %x\n",87 __FUNCTION__ , this, parent_ptr, parent_cxy );86 printk("\n[DBG] %s : thread %x in process %x get parent process %x in cluster %x\n", 87 __FUNCTION__, this->trdid, process->pid, parent_ptr, parent_cxy ); 88 88 #endif 89 89 … … 99 99 100 100 #if( DEBUG_SYS_EXIT & 1) 101 if( tm_start > DEBUG_SYS_EXIT)102 printk("\n[DBG] %s : thread %x removed process %x from TXT list\n",103 __FUNCTION__ , this,pid );101 if( DEBUG_SYS_EXIT < tm_start ) 102 printk("\n[DBG] %s : thread %x in process %x detached process from TXT\n", 103 __FUNCTION__, this->trdid, process->pid ); 104 104 #endif 105 105 … … 107 107 // but the main thread and this calling thread 108 108 hal_enable_irq( &save_sr ); 109 process_sigaction( p id , DELETE_ALL_THREADS );109 process_sigaction( process->pid , DELETE_ALL_THREADS ); 110 110 hal_restore_irq( save_sr ); 111 111 112 112 #if( DEBUG_SYS_EXIT & 1) 113 if( tm_start > DEBUG_SYS_EXIT)114 printk("\n[DBG] %s : thread %x deleted threads for process %x\n",115 __FUNCTION__ , this,pid );113 if( DEBUG_SYS_EXIT < tm_start ) 114 printk("\n[DBG] %s : thread %x in process %x deleted all threads but itself\n", 115 __FUNCTION__, this->trdid, process->pid ); 116 116 #endif 117 117 … … 122 122 #if( DEBUG_SYS_EXIT & 1) 123 123 if( tm_start > DEBUG_SYS_EXIT ) 124 printk("\n[DBG] %s : calling thread %x marked iself for delete in process %x\n",125 __FUNCTION__ , this,pid );124 printk("\n[DBG] %s : thread %x in process %x marked iself for delete\n", 125 __FUNCTION__, this->trdid, process->pid ); 126 126 #endif 127 127 thread_delete( XPTR( local_cxy , this ) , pid , true ); … … 133 133 #if( DEBUG_SYS_EXIT & 1) 134 134 if( tm_start > DEBUG_SYS_EXIT ) 135 printk("\n[DBG] %s : thread %x blocked main thread for process %x\n",136 __FUNCTION__, this ,pid );135 printk("\n[DBG] %s : thread %x in process %x blocked main thread\n", 136 __FUNCTION__, this->trdid, process->pid ); 137 137 #endif 138 138 … … 144 144 #if( DEBUG_SYS_EXIT & 1) 145 145 if( tm_start > DEBUG_SYS_EXIT ) 146 printk("\n[DBG] %s : thread %x set exit status in process %x / term_state %x\n",147 __FUNCTION__ , this,pid, term_state );146 printk("\n[DBG] %s : thread %x in process %x set exit status %x in owner process\n", 147 __FUNCTION__, this->trdid, process->pid, term_state ); 148 148 #endif 149 149 150 // take the children lock andunblock the parent process main thread150 // unblock the parent process main thread 151 151 remote_spinlock_lock( children_lock_xp ); 152 152 thread_unblock( parent_main_xp , THREAD_BLOCKED_WAIT ); … … 155 155 #if( DEBUG_SYS_EXIT & 1) 156 156 if( tm_start > DEBUG_SYS_EXIT ) 157 printk("\n[DBG] %s : thread %x in cluster %x unblock parent main thread %x in cluster %x\n", 158 __FUNCTION__ , this, local_cxy, parent_main_ptr, parent_cxy ); 157 printk("\n[DBG] %s : thread %x in process %x unblock parent main thread in process %x\n", 158 __FUNCTION__ , this->trdid, process->pid, 159 hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid) ) ); 159 160 #endif 160 161 … … 164 165 tm_end = hal_get_cycles(); 165 166 if( DEBUG_SYS_EXIT < tm_end ) 166 printk("\n[DBG] %s : thread %x exit / process %x / status %x / cost = %d / cycle %d\n", 167 __FUNCTION__, this, pid, status, (uint32_t)(tm_end - tm_start), (uint32_t)tm_end ); 167 printk("\n[DBG] %s : thread %x in process %x exit / status %x / cost = %d / cycle %d\n", 168 __FUNCTION__, this->trdid, process->pid, status, 169 (uint32_t)(tm_end - tm_start), (uint32_t)tm_end ); 168 170 #endif 169 171 -
trunk/kernel/syscalls/sys_fg.c
r446 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_irqmask.h> 27 27 #include <errno.h> -
trunk/kernel/syscalls/sys_fork.c
r440 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_context.h> 27 27 #include <hal_switch.h> … … 70 70 tm_start = hal_get_cycles(); 71 71 if( DEBUG_SYS_FORK < tm_start ) 72 printk("\n[DBG] %s : parent_thread %x enter / parent_pid %x/ cycle = %d\n",73 __FUNCTION__, parent_thread_ptr , parent_pid, (uint32_t)tm_start );72 printk("\n[DBG] %s : thread %x in process %x enter / cycle = %d\n", 73 __FUNCTION__, parent_thread_ptr->trdid, parent_pid, (uint32_t)tm_start ); 74 74 #endif 75 75 … … 106 106 #if (DEBUG_SYS_FORK & 1 ) 107 107 if( DEBUG_SYS_FORK < tm_start ) 108 printk("\n[DBG] %s : parent_thread%x selected cluster %x\n",109 __FUNCTION__, parent_thread_ptr , child_cxy );108 printk("\n[DBG] %s : thread %x in process %x selected cluster %x\n", 109 __FUNCTION__, parent_thread_ptr->trdid, parent_pid, child_cxy ); 110 110 #endif 111 111 … … 165 165 tm_end = hal_get_cycles(); 166 166 if( DEBUG_SYS_FORK < tm_end ) 167 printk("\n[DBG] %s : p arent_thread %x on cluster%x exit / cost = %d / cycle %d\n",168 __FUNCTION__, parent_ thread_ptr, parent_cxy, (uint32_t)(tm_end - tm_start), (uint32_t)tm_end );167 printk("\n[DBG] %s : process %x exit / cost = %d / cycle %d\n", 168 __FUNCTION__, parent_pid, (uint32_t)(tm_end - tm_start), (uint32_t)tm_end ); 169 169 #endif 170 171 170 return child_pid; 172 171 } … … 177 176 tm_end = hal_get_cycles(); 178 177 if( DEBUG_SYS_FORK < tm_end ) 179 printk("\n[DBG] %s : child_thread %x on cluster%x exit / cost = %d / cycle %d\n",180 __FUNCTION__, child_ thread_ptr, child_cxy, (uint32_t)(tm_end - tm_start), (uint32_t)tm_end );178 printk("\n[DBG] %s : process %x exit / cost = %d / cycle %d\n", 179 __FUNCTION__, child_pid, (uint32_t)(tm_end - tm_start), (uint32_t)tm_end ); 181 180 #endif 182 183 181 return 0; 184 182 } -
trunk/kernel/syscalls/sys_get_config.c
r440 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_uspace.h> 26 26 #include <hal_special.h> -
trunk/kernel/syscalls/sys_get_core.c
r440 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_uspace.h> 26 26 #include <hal_special.h> -
trunk/kernel/syscalls/sys_get_cycle.c
r440 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_uspace.h> 26 26 #include <hal_special.h> -
trunk/kernel/syscalls/sys_getcwd.c
r440 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_uspace.h> 27 27 #include <hal_special.h> -
trunk/kernel/syscalls/sys_isatty.c
r438 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_uspace.h> 27 27 #include <hal_irqmask.h> -
trunk/kernel/syscalls/sys_kill.c
r448 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_irqmask.h> 27 27 #include <errno.h> -
trunk/kernel/syscalls/sys_lseek.c
r23 r457 22 22 23 23 #include <kernel_config.h> 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_uspace.h> 26 26 #include <errno.h> -
trunk/kernel/syscalls/sys_mkdir.c
r407 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_uspace.h> 26 26 #include <vfs.h> -
trunk/kernel/syscalls/sys_mkfifo.c
r407 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_uspace.h> 26 26 #include <printk.h> -
trunk/kernel/syscalls/sys_mmap.c
r440 r457 23 23 */ 24 24 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_uspace.h> 27 27 #include <hal_irqmask.h> -
trunk/kernel/syscalls/sys_munmap.c
r438 r457 23 23 */ 24 24 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_uspace.h> 27 27 #include <shared_syscalls.h> -
trunk/kernel/syscalls/sys_mutex.c
r440 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_special.h> 26 26 #include <errno.h> -
trunk/kernel/syscalls/sys_open.c
r407 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_uspace.h> 27 27 #include <errno.h> -
trunk/kernel/syscalls/sys_opendir.c
r407 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <thread.h> 26 26 #include <process.h> -
trunk/kernel/syscalls/sys_pipe.c
r407 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <vfs.h> 26 26 #include <process.h> -
trunk/kernel/syscalls/sys_read.c
r450 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_uspace.h> 27 27 #include <hal_irqmask.h> -
trunk/kernel/syscalls/sys_readdir.c
r407 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_uspace.h> 27 27 #include <errno.h> -
trunk/kernel/syscalls/sys_rmdir.c
r407 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_uspace.h> 26 26 #include <printk.h> -
trunk/kernel/syscalls/sys_sem.c
r440 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_uspace.h> 26 #include <shared_semaphore.h> 26 27 #include <errno.h> 27 28 #include <thread.h> … … 31 32 #include <syscalls.h> 32 33 34 #if DEBUG_SYS_SEM 35 ////////////////////////////////////////////////// 36 static char * sys_sem_op_str( uint32_t operation ) 37 { 38 if ( operation == SEM_INIT ) return "INIT"; 39 else if( operation == SEM_WAIT ) return "WAIT"; 40 else if( operation == SEM_POST ) return "POST"; 41 else if( operation == SEM_GETVALUE ) return "GETVALUE"; 42 else if( operation == SEM_DESTROY ) return "DESTROY"; 43 else return "undefined"; 44 } 45 #endif 46 33 47 ////////////////////////////////// 34 int sys_sem( void * vaddr, // semaphore virtual address 35 uint32_t operation, // requested operation type 36 uint32_t * value ) // pointer on in/out argument 48 int sys_sem( void * vaddr, // semaphore virtual address 49 uint32_t operation, // requested operation type 50 uint32_t init_value, // initial value 51 uint32_t * current_value ) // pointer on current value buffer 37 52 { 38 uint32_t data;39 53 vseg_t * vseg; 40 54 error_t error; 55 uint32_t current; // semaphore current value 56 xptr_t sem_xp; // extended pointer on semaphore 41 57 42 58 thread_t * this = CURRENT_THREAD; 43 59 process_t * process = this->process; 60 61 #if DEBUG_SYS_SEM 62 uint64_t tm_start; 63 uint64_t tm_end; 64 tm_start = hal_get_cycles(); 65 if( DEBUG_SYS_SEM < tm_start ) 66 printk("\n[DBG] %s : thread %x in process %x enter for %s / cycle %d\n", 67 __FUNCTION__, this->trdid, process->pid, sys_sem_op_str( operation ), (uint32_t)tm_start ); 68 #endif 44 69 45 70 // check vaddr in user vspace … … 49 74 50 75 #if DEBUG_SYSCALLS_ERROR 51 printk("\n[ERROR] in %s : unmapped semaphore %x / thread %x / process %x\n", 52 __FUNCTION__ , (intptr_t)vaddr, this->trdid, process->pid ); 53 vmm_display( process , false ); 54 #endif 55 this->errno = EINVAL; 56 return -1; 57 } 58 59 // check value in user vspace 60 error = vmm_get_vseg( process , (intptr_t)value , &vseg ); 61 if( error ) 62 { 63 64 #if DEBUG_SYSCALLS_ERROR 65 printk("\n[ERROR] in %s : unmapped value %x / thread %x / process %x\n", 76 printk("\n[ERROR] in %s : unmapped semaphore pointer %x / thread %x in process %x\n", 66 77 __FUNCTION__ , (intptr_t)vaddr, this->trdid, process->pid ); 67 78 vmm_display( process , false ); … … 77 88 case SEM_INIT: 78 89 { 79 // get argument 80 hal_copy_from_uspace( &data , value , sizeof(uint32_t) ); 81 82 // call init function 83 error = remote_sem_create( (intptr_t)vaddr , data ); 90 // call relevant kernel function to initialize semaphore 91 error = remote_sem_create( (intptr_t)vaddr , 92 init_value, 93 XPTR( local_cxy , &sem_xp ) ); 84 94 85 95 if ( error ) 86 96 { 87 printk("\n[ERROR] in %s : cannot create semaphore = %x\n", 88 __FUNCTION__ , (intptr_t)value ); 89 this->errno = error; 90 return -1; 91 } 97 98 #if DEBUG_SYSCALLS_ERROR 99 printk("\n[ERROR] in %s : cannot create semaphore / thread %x in process %x\n", 100 __FUNCTION__, this->trdid, process->pid ); 101 #endif 102 this->errno = ENOMEM; 103 return -1; 104 } 105 92 106 break; 93 107 } … … 95 109 case SEM_GETVALUE: 96 110 { 97 // get extended pointer on remote semaphore 98 xptr_t sem_xp = remote_sem_from_vaddr( (intptr_t)vaddr ); 99 100 if( sem_xp == XPTR_NULL ) // user error 101 { 102 103 #if DEBUG_SYSCALLS_ERROR 104 printk("\n[ERROR] in %s : semaphore %x not registered / thread %x / process %x\n", 105 __FUNCTION__ , (intptr_t)value, this->trdid, process->pid ); 106 #endif 107 this->errno = EINVAL; 108 return -1; 109 } 110 else // success 111 { 112 // get semaphore current value 113 remote_sem_get_value( sem_xp , &data ); 111 // check current_value buffer in user vspace 112 error = vmm_get_vseg( process , (intptr_t)current_value , &vseg ); 113 if( error ) 114 { 115 116 #if DEBUG_SYSCALLS_ERROR 117 printk("\n[ERROR] in %s : unmapped buffer for current value %x / thread %x in process %x\n", 118 __FUNCTION__ , (intptr_t)current_value, this->trdid, process->pid ); 119 vmm_display( process , false ); 120 #endif 121 this->errno = EINVAL; 122 return -1; 123 } 124 125 // get extended pointer on remote semaphore 126 sem_xp = remote_sem_from_vaddr( (intptr_t)vaddr ); 127 128 // check semaphore registered 129 if( sem_xp == XPTR_NULL ) 130 { 131 132 #if DEBUG_SYSCALLS_ERROR 133 printk("\n[ERROR] in %s : semaphore %x not registered / thread %x in process %x\n", 134 __FUNCTION__ , (intptr_t)vaddr, this->trdid, process->pid ); 135 #endif 136 this->errno = EINVAL; 137 return -1; 138 } 139 140 // call relevant kernel function to get semaphore current value 141 remote_sem_get_value( sem_xp , ¤t ); 114 142 115 116 hal_copy_to_uspace( value , &data, sizeof(uint32_t) );117 } 143 // return value to user 144 hal_copy_to_uspace( current_value , ¤t , sizeof(uint32_t) ); 145 118 146 break; 119 147 } … … 122 150 { 123 151 // get extended pointer on remote semaphore 124 xptr_tsem_xp = remote_sem_from_vaddr( (intptr_t)vaddr );125 126 if( sem_xp == XPTR_NULL ) // user error127 {128 129 #if DEBUG_SYSCALLS_ERROR 130 printk("\n[ERROR] in %s : semaphore %x not registered / thread %x / process %x\n", 131 __FUNCTION__ , (intptr_t)value, this->trdid, process->pid ); 132 #endif 133 this->errno = EINVAL; 134 return -1;135 }136 else // success137 { 138 //wait semaphore available139 140 }152 sem_xp = remote_sem_from_vaddr( (intptr_t)vaddr ); 153 154 // check semaphore registered 155 if( sem_xp == XPTR_NULL ) 156 { 157 158 #if DEBUG_SYSCALLS_ERROR 159 printk("\n[ERROR] in %s : semaphore %x not registered / thread %x in process %x\n", 160 __FUNCTION__ , (intptr_t)vaddr, this->trdid, process->pid ); 161 #endif 162 this->errno = EINVAL; 163 return -1; 164 } 165 166 // call relevant kernel function to wait semaphore available 167 remote_sem_wait( sem_xp ); 168 141 169 break; 142 170 } … … 145 173 { 146 174 // get extended pointer on remote semaphore 147 xptr_tsem_xp = remote_sem_from_vaddr( (intptr_t)vaddr );148 149 if( sem_xp == XPTR_NULL ) // user error150 {151 152 #if DEBUG_SYSCALLS_ERROR 153 printk("\n[ERROR] in %s : semaphore %x not registered / thread %x / process %x\n", 154 __FUNCTION__ , (intptr_t)value, this->trdid, process->pid ); 155 #endif 156 this->errno = EINVAL; 157 return -1;158 }159 else // success160 { 161 //release semaphore162 163 } 175 sem_xp = remote_sem_from_vaddr( (intptr_t)vaddr ); 176 177 // check semaphore registered 178 if( sem_xp == XPTR_NULL ) 179 { 180 181 #if DEBUG_SYSCALLS_ERROR 182 printk("\n[ERROR] in %s : semaphore %x not registered / thread %x in process %x\n", 183 __FUNCTION__ , (intptr_t)vaddr, this->trdid, process->pid ); 184 #endif 185 this->errno = EINVAL; 186 return -1; 187 } 188 189 // call relevant kernel function to release semaphore 190 remote_sem_post( sem_xp ); 191 164 192 break; 165 193 } … … 168 196 { 169 197 // get extended pointer on remote semaphore 170 xptr_tsem_xp = remote_sem_from_vaddr( (intptr_t)vaddr );171 172 if( sem_xp == XPTR_NULL ) // user error173 {174 175 #if DEBUG_SYSCALLS_ERROR 176 printk("\n[ERROR] in %s : semaphore %x not registered / thread %x / process %x\n", 177 __FUNCTION__ , (intptr_t)value, this->trdid, process->pid ); 178 #endif 179 this->errno = EINVAL; 180 return -1;181 }182 else // success183 { 184 185 186 } 198 sem_xp = remote_sem_from_vaddr( (intptr_t)vaddr ); 199 200 // check semaphore registered 201 if( sem_xp == XPTR_NULL ) 202 { 203 204 #if DEBUG_SYSCALLS_ERROR 205 printk("\n[ERROR] in %s : semaphore %x not registered / thread %x in process %x\n", 206 __FUNCTION__ , (intptr_t)vaddr, this->trdid, process->pid ); 207 #endif 208 this->errno = EINVAL; 209 return -1; 210 } 211 212 // destroy semaphore 213 remote_sem_destroy( sem_xp ); 214 187 215 break; 188 216 } … … 190 218 default: // undefined operation 191 219 { 192 printk("\n[PANIC] in %s : illegal operation type\n", __FUNCTION__ ); 193 hal_core_sleep(); 220 221 #if DEBUG_SYSCALLS_ERROR 222 printk("\n[ERROR] in %s : undefined operation type %d / thread %x in process %x\n", 223 __FUNCTION__ , operation, this->trdid, process->pid ); 224 #endif 225 this->errno = EINVAL; 226 return -1; 194 227 } 195 228 } 196 229 230 hal_fence(); 231 232 #if DEBUG_SYS_SEM 233 tm_end = hal_get_cycles(); 234 if( DEBUG_SYS_SEM < tm_end ) 235 { 236 cxy_t sem_cxy = GET_CXY( sem_xp ); 237 remote_sem_t * sem_ptr = GET_PTR( sem_xp ); 238 uint32_t value = hal_remote_lw( XPTR( sem_cxy , &sem_ptr->count ) ); 239 printk("\n[DBG] %s : thread %x in process %x exit for %s / value %d / cost = %d / cycle %d\n", 240 __FUNCTION__, this->trdid, process->pid, sys_sem_op_str( operation ), value, 241 (uint32_t)(tm_end - tm_start), (uint32_t)tm_end ); 242 } 243 #endif 244 197 245 return 0; 198 246 -
trunk/kernel/syscalls/sys_signal.c
r435 r457 23 23 */ 24 24 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <errno.h> 27 27 #include <thread.h> -
trunk/kernel/syscalls/sys_stat.c
r440 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_uspace.h> 26 26 #include <hal_special.h> -
trunk/kernel/syscalls/sys_thread_cancel.c
r443 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_irqmask.h> 26 26 #include <hal_remote.h> -
trunk/kernel/syscalls/sys_thread_create.c
r440 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_uspace.h> 27 27 #include <printk.h> -
trunk/kernel/syscalls/sys_thread_detach.c
r23 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_remote.h> 26 26 #include <hal_special.h> -
trunk/kernel/syscalls/sys_thread_exit.c
r440 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_irqmask.h> 26 26 #include <thread.h> -
trunk/kernel/syscalls/sys_thread_join.c
r438 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_remote.h> 26 26 #include <hal_special.h> -
trunk/kernel/syscalls/sys_thread_wakeup.c
r438 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <thread.h> 26 26 #include <printk.h> -
trunk/kernel/syscalls/sys_thread_yield.c
r445 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_special.h> 26 26 #include <scheduler.h> -
trunk/kernel/syscalls/sys_timeofday.c
r440 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_uspace.h> 26 26 #include <thread.h> -
trunk/kernel/syscalls/sys_trace.c
r443 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_special.h> 26 26 #include <printk.h> -
trunk/kernel/syscalls/sys_unlink.c
r407 r457 21 21 */ 22 22 23 #include <hal_ types.h>23 #include <hal_kernel_types.h> 24 24 #include <hal_uspace.h> 25 25 #include <vfs.h> -
trunk/kernel/syscalls/sys_utls.c
r23 r457 23 23 */ 24 24 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <errno.h> 27 27 #include <thread.h> -
trunk/kernel/syscalls/sys_wait.c
r446 r457 22 22 */ 23 23 24 #include <hal_ types.h>24 #include <hal_kernel_types.h> 25 25 #include <hal_uspace.h> 26 26 #include <hal_irqmask.h> -
trunk/kernel/syscalls/sys_write.c
r443 r457 23 23 24 24 #include <kernel_config.h> 25 #include <hal_ types.h>25 #include <hal_kernel_types.h> 26 26 #include <hal_uspace.h> 27 27 #include <hal_irqmask.h> -
trunk/kernel/syscalls/syscalls.h
r445 r457 2 2 * syscalls.h - Kernel side services for syscall handling. 3 3 * 4 * Author Alain Greiner (2016,2017 )4 * Author Alain Greiner (2016,2017,2018) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 25 25 #define _SYSCALLS_H_ 26 26 27 #include <hal_ types.h>27 #include <hal_kernel_types.h> 28 28 #include <shared_syscalls.h> 29 29 … … 116 116 * and the code implementing the operations is in the remore_sem.c file. 117 117 ****************************************************************************************** 118 * @ vaddr : semaphore virtual address in user space == identifier. 119 * @ operation : SEM_INIT / SEM_DESTROY / SEM_GETVALUE / SEM_POST / SEM_WAIT. 120 * @ value : pointer on in/out argument in user space. 118 * @ vaddr : semaphore virtual address in user space == identifier. 119 * @ operation : SEM_INIT / SEM_DESTROY / SEM_GETVALUE / SEM_POST / SEM_WAIT. 120 * @ init_value : initial semaphore value. 121 * @ current_value : pointer on buffer for current semaphore value. 121 122 * @ return 0 if success / return -1 if failure. 122 123 *****************************************************************************************/ 123 124 int sys_sem( void * vaddr, 124 125 uint32_t operation, 125 uint32_t * value ); 126 uint32_t init_value, 127 uint32_t * current_value ); 126 128 127 129 /****************************************************************************************** … … 584 586 585 587 /****************************************************************************************** 588 * [44] TBD 589 ****************************************************************************************** 590 * @ cxy : cluster identifier. 591 * @ lid : core local index. 592 * @ return 0 if success / return -1 if failure. 593 *****************************************************************************************/ 594 int sys_place( uint32_t cxy, 595 uint32_t lid ); 596 597 /****************************************************************************************** 586 598 * [45] This function block the calling thread on the THREAD_BLOCKED_GLOBAL condition, 587 599 * and deschedule. … … 624 636 625 637 /****************************************************************************************** 626 * [49] TBD 627 ****************************************************************************************** 628 * @ cxy : cluster identifier. 629 * @ lid : core local index. 630 * @ return 0 if success / return -1 if failure. 631 *****************************************************************************************/ 632 int sys_place( uint32_t cxy, 633 uint32_t lid ); 638 * [49] This function returns a non-zero value in the <is_fg> buffer when the process 639 * identified by the <pid> argument is the current TXT owner. 640 ****************************************************************************************** 641 * @ pid : process identifier. 642 * @ is_fg : pointer on buffer. 643 * @ return 0 if success / return -1 if failure. 644 *****************************************************************************************/ 645 int sys_is_fg( pid_t pid, 646 uint32_t * is_fg ); 634 647 635 648 #endif // _SYSCALLS_H_
Note: See TracChangeset
for help on using the changeset viewer.