Changeset 443
- Timestamp:
- May 16, 2018, 4:15:22 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 33 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Makefile
r440 r443 41 41 user/ksh/build/ksh.elf \ 42 42 user/pgdc/build/pgcd.elf \ 43 user/ hello/build/hello.elf\43 user/idbg/build/idbg.elf \ 44 44 user/sort/build/sort.elf 45 45 … … 63 63 user/ksh/build/ksh.elf \ 64 64 user/pgcd/build/pgcd.elf \ 65 user/ hello/build/hello.elf\65 user/idbg/build/idbg.elf \ 66 66 user/sort/build/sort.elf \ 67 67 list … … 94 94 $(MAKE) -C user/sort clean 95 95 $(MAKE) -C user/pgcd clean 96 $(MAKE) -C user/ helloclean96 $(MAKE) -C user/idbg clean 97 97 $(MAKE) -C $(HAL_ARCH) clean 98 98 … … 164 164 $(MAKE) -C user/pgcd 165 165 mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user 166 user/ hello/build/hello.elf: build_libs167 $(MAKE) -C user/ hello166 user/idbg/build/idbg.elf: build_libs 167 $(MAKE) -C user/idbg 168 168 mcopy -o -i $(DISK_IMAGE) $@ ::/bin/user 169 169 user/sort/build/sort.elf: build_libs -
trunk/hal/tsar_mips32/core/hal_gpt.c
r440 r443 132 132 xptr_t page_xp; 133 133 134 #if DEBUG_ GPT_ACCESS134 #if DEBUG_HAL_GPT_CREATE 135 135 uint32_t cycle = (uint32_t)hal_get_cycles; 136 if( DEBUG_ GPT_ACCESS< cycle )136 if( DEBUG_HAL_GPT_CREATE < cycle ) 137 137 printk("\n[DBG] %s : thread %x enter / cycle %d\n", 138 138 __FUNCTION__, CURRENT_THREAD, cycle ); … … 161 161 gpt->ppn = ppm_page2ppn( page_xp ); 162 162 163 #if DEBUG_ GPT_ACCESS163 #if DEBUG_HAL_GPT_CREATE 164 164 cycle = (uint32_t)hal_get_cycles; 165 if( DEBUG_ GPT_ACCESS< cycle )165 if( DEBUG_HAL_GPT_CREATE < cycle ) 166 166 printk("\n[DBG] %s : thread %x exit / cycle %d\n", 167 167 __FUNCTION__, CURRENT_THREAD, cycle ); … … 186 186 kmem_req_t req; 187 187 bool_t is_ref; 188 189 #if DEBUG_HAL_GPT_DESTROY 190 uint32_t cycle = (uint32_t)hal_get_cycles; 191 if( DEBUG_HAL_GPT_DESTROY < cycle ) 192 printk("\n[DBG] %s : thread %x enter / cycle %d\n", 193 __FUNCTION__, CURRENT_THREAD, cycle ); 194 #endif 188 195 189 196 // get pointer on calling process … … 252 259 req.ptr = GET_PTR( ppm_base2page( XPTR(local_cxy , pt1 ) ) ); 253 260 kmem_free( &req ); 261 262 #if DEBUG_HAL_GPT_DESTROY 263 cycle = (uint32_t)hal_get_cycles; 264 if( DEBUG_HAL_GPT_DESTROY < cycle ) 265 printk("\n[DBG] %s : thread %x exit / cycle %d\n", 266 __FUNCTION__, CURRENT_THREAD, cycle ); 267 #endif 254 268 255 269 } // end hal_gpt_destroy() … … 340 354 uint32_t tsar_attr; // PTE attributes for TSAR MMU 341 355 342 #if DEBUG_ GPT_ACCESS356 #if DEBUG_HAL_GPT_ACCESS 343 357 uint32_t cycle = (uint32_t)hal_get_cycles; 344 if( DEBUG_ GPT_ACCESS < cycle )358 if( DEBUG_HAL_GPT_ACCESS < cycle ) 345 359 printk("\n[DBG] %s : thread %x enter / vpn %x / attr %x / ppn %x / cycle %d\n", 346 360 __FUNCTION__, CURRENT_THREAD, vpn, attr, ppn, cycle ); … … 357 371 tsar_attr = gpt2tsar( attr ); 358 372 359 #if (DEBUG_ GPT_ACCESS & 1)360 if( DEBUG_ GPT_ACCESS < cycle )373 #if (DEBUG_HAL_GPT_ACCESS & 1) 374 if( DEBUG_HAL_GPT_ACCESS < cycle ) 361 375 printk("\n[DBG] %s : thread %x / vpn %x / &pt1 %x / tsar_attr %x\n", 362 376 __FUNCTION__, CURRENT_THREAD, vpn, pt1, tsar_attr ); … … 392 406 pte1 = *pte1_ptr; 393 407 394 #if (DEBUG_ GPT_ACCESS & 1)395 if( DEBUG_ GPT_ACCESS < cycle )408 #if (DEBUG_HAL_GPT_ACCESS & 1) 409 if( DEBUG_HAL_GPT_ACCESS < cycle ) 396 410 printk("\n[DBG] %s : thread %x / vpn %x / current_pte1 %x\n", 397 411 __FUNCTION__, CURRENT_THREAD, vpn, pte1 ); … … 437 451 pt2 = (uint32_t *)GET_PTR( ppm_ppn2base( pt2_ppn ) ); 438 452 439 #if (DEBUG_ GPT_ACCESS & 1)440 if( DEBUG_ GPT_ACCESS < cycle )453 #if (DEBUG_HAL_GPT_ACCESS & 1) 454 if( DEBUG_HAL_GPT_ACCESS < cycle ) 441 455 printk("\n[DBG] %s : thread %x / vpn %x / pte1 %x / &pt2 %x\n", 442 456 __FUNCTION__, CURRENT_THREAD, vpn, pte1, pt2 ); … … 452 466 hal_fence(); 453 467 454 #if DEBUG_ GPT_ACCESS468 #if DEBUG_HAL_GPT_ACCESS 455 469 cycle = (uint32_t)hal_get_cycles; 456 if( DEBUG_ GPT_ACCESS < cycle )470 if( DEBUG_HAL_GPT_ACCESS < cycle ) 457 471 printk("\n[DBG] %s : thread %x exit / vpn %x / pte2_attr %x / pte2_ppn %x / cycle %d\n", 458 472 __FUNCTION__, CURRENT_THREAD, vpn, pt2[2 * ix2], pt2[2 * ix2 + 1], cycle ); … … 762 776 ppn_t dst_pt2_ppn; 763 777 764 #if DEBUG_ GPT_ACCESS778 #if DEBUG_HAL_GPT_ACCESS 765 779 uint32_t cycle = (uint32_t)hal_get_cycles; 766 if( DEBUG_ GPT_ACCESS < cycle )780 if( DEBUG_HAL_GPT_ACCESS < cycle ) 767 781 printk("\n[DBG] %s : thread %x enter / vpn %x / cycle %d\n", 768 782 __FUNCTION__, CURRENT_THREAD, vpn, cycle ); … … 853 867 *ppn = src_pte2_ppn; 854 868 855 #if DEBUG_ GPT_ACCESS869 #if DEBUG_HAL_GPT_ACCESS 856 870 cycle = (uint32_t)hal_get_cycles; 857 if( DEBUG_ GPT_ACCESS < cycle )871 if( DEBUG_HAL_GPT_ACCESS < cycle ) 858 872 printk("\n[DBG] %s : thread %x exit / copy done for vpn %x / cycle %d\n", 859 873 __FUNCTION__, CURRENT_THREAD, vpn, cycle ); … … 870 884 *ppn = 0; 871 885 872 #if DEBUG_ GPT_ACCESS886 #if DEBUG_HAL_GPT_ACCESS 873 887 cycle = (uint32_t)hal_get_cycles; 874 if( DEBUG_ GPT_ACCESS < cycle )888 if( DEBUG_HAL_GPT_ACCESS < cycle ) 875 889 printk("\n[DBG] %s : thread %x exit / nothing done for vpn %x / cycle %d\n", 876 890 __FUNCTION__, CURRENT_THREAD, vpn, cycle ); -
trunk/hal/tsar_mips32/core/hal_ppm.c
r432 r443 101 101 } 102 102 103 // printk("\n@@@ in %s : reserved = %d / total = %d\n", __FUNCTION__, reserved_pages, pages_nr );104 105 103 // - set PG_RESERVED flag for reserved pages (kernel code & pages_tbl[]) 106 104 // - release all other pages to populate the free lists … … 115 113 // TODO optimisation : decompose this enormous set of small pages 116 114 // to several sets of big pages with various order values [AG] 117 118 // if( (i < (reserved_pages+10)) || (i > (pages_nr-5)) ) ppm_print();119 120 115 } 121 116 122 // assert( false , __FUNCTION__ , "PMM init completed\n");123 124 117 // check consistency 125 118 return ppm_assert_order( ppm ); -
trunk/kernel/kern/cluster.c
r440 r443 34 34 #include <spinlock.h> 35 35 #include <core.h> 36 #include <chdev.h> 36 37 #include <scheduler.h> 37 38 #include <list.h> … … 49 50 ///////////////////////////////////////////////////////////////////////////////////// 50 51 51 extern process_t process_zero; // allocated in kernel_init.c file52 53 54 /////////////////////////////////////////////// //52 extern process_t process_zero; // allocated in kernel_init.c file 53 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c file 54 55 ///////////////////////////////////////////////n 55 56 error_t cluster_init( struct boot_info_s * info ) 56 57 { … … 252 253 253 254 ////////////////////////////////////////////////////// 255 xptr_t cluster_get_process_from_pid_in_cxy( cxy_t cxy, 256 pid_t pid ) 257 { 258 xptr_t root_xp; // xptr on root of list of processes in owner cluster 259 xptr_t lock_xp; // xptr on lock protecting this list 260 xptr_t iter_xp; // iterator 261 xptr_t current_xp; // xptr on current process descriptor 262 bool_t found; 263 264 cluster_t * cluster = LOCAL_CLUSTER; 265 266 // get owner cluster and lpid 267 cxy_t owner_cxy = CXY_FROM_PID( pid ); 268 lpid_t lpid = LPID_FROM_PID( pid ); 269 270 // get lock & root of list of copies from owner cluster 271 root_xp = XPTR( owner_cxy , &cluster->pmgr.copies_root[lpid] ); 272 lock_xp = XPTR( owner_cxy , &cluster->pmgr.copies_lock[lpid] ); 273 274 // take the lock protecting the list of processes 275 remote_spinlock_lock( lock_xp ); 276 277 // scan list of processes 278 found = false; 279 XLIST_FOREACH( root_xp , iter_xp ) 280 { 281 current_xp = XLIST_ELEMENT( iter_xp , process_t , copies_list ); 282 283 if( GET_CXY( current_xp ) == cxy ) 284 { 285 found = true; 286 break; 287 } 288 } 289 290 // release the lock protecting the list of processes 291 remote_spinlock_unlock( lock_xp ); 292 293 // return extended pointer on process descriptor in owner cluster 294 if( found ) return current_xp; 295 else return XPTR_NULL; 296 297 } // end cluster_get_process_from_pid_in_cxy() 298 299 300 ////////////////////////////////////////////////////// 254 301 xptr_t cluster_get_owner_process_from_pid( pid_t pid ) 255 302 { … … 298 345 } // end cluster_get_owner_process_from_pid() 299 346 347 300 348 ////////////////////////////////////////////////////////// 301 349 xptr_t cluster_get_reference_process_from_pid( pid_t pid ) … … 459 507 void cluster_process_local_link( process_t * process ) 460 508 { 461 uint32_t irq_state; 509 reg_t save_sr; 510 462 511 pmgr_t * pm = &LOCAL_CLUSTER->pmgr; 463 512 513 // get extended pointers on local process list root & lock 514 xptr_t root_xp = XPTR( local_cxy , &pm->local_root ); 515 xptr_t lock_xp = XPTR( local_cxy , &pm->local_lock ); 516 464 517 // get lock protecting the process manager local list 465 remote_spinlock_lock_busy( XPTR( local_cxy , &pm->local_lock ) , & irq_state);466 467 xlist_add_last( XPTR( local_cxy , &pm->local_root ),468 518 remote_spinlock_lock_busy( lock_xp , &save_sr ); 519 520 // register process in local list 521 xlist_add_last( root_xp , XPTR( local_cxy , &process->local_list ) ); 469 522 pm->local_nr++; 470 523 471 524 // release lock protecting the process manager local list 472 remote_spinlock_unlock_busy( XPTR( local_cxy , &pm->local_lock ) , irq_state);525 remote_spinlock_unlock_busy( lock_xp , save_sr ); 473 526 } 474 527 … … 476 529 void cluster_process_local_unlink( process_t * process ) 477 530 { 478 uint32_t irq_state; 531 reg_t save_sr; 532 479 533 pmgr_t * pm = &LOCAL_CLUSTER->pmgr; 480 534 535 // get extended pointers on local process list lock 536 xptr_t lock_xp = XPTR( local_cxy , &pm->local_lock ); 537 481 538 // get lock protecting the process manager local list 482 remote_spinlock_lock_busy( XPTR( local_cxy , &pm->local_lock ) , &irq_state ); 483 539 remote_spinlock_lock_busy( lock_xp , &save_sr ); 540 541 // remove process from local list 484 542 xlist_unlink( XPTR( local_cxy , &process->local_list ) ); 485 543 pm->local_nr--; 486 544 487 545 // release lock protecting the process manager local list 488 remote_spinlock_unlock_busy( XPTR( local_cxy , &pm->local_lock ) , irq_state);546 remote_spinlock_unlock_busy( lock_xp , save_sr ); 489 547 } 490 548 … … 582 640 { 583 641 xptr_t root_xp; 642 xptr_t lock_xp; 584 643 xptr_t iter_xp; 585 xptr_t process_xp; 586 587 // get extended pointer on root of process in cluster cxy 644 xptr_t process_xp; 645 cxy_t txt0_cxy; 646 chdev_t * txt0_ptr; 647 xptr_t txt0_xp; 648 xptr_t txt0_lock_xp; 649 reg_t txt0_save_sr; // save SR to take TXT0 lock in busy mode 650 651 assert( (cluster_is_undefined( cxy ) == false), 652 __FUNCTION__, "illegal cluster index" ); 653 654 // get extended pointer on root and lock for local process list in cluster 588 655 root_xp = XPTR( cxy , &LOCAL_CLUSTER->pmgr.local_root ); 589 590 // skip one line 591 printk("\n***** processes in cluster %x / cycle %d\n", cxy , (uint32_t)hal_get_cycles() ); 592 593 // loop on all reference processes in cluster cxy 656 lock_xp = XPTR( cxy , &LOCAL_CLUSTER->pmgr.local_lock ); 657 658 // get pointers on TXT0 chdev 659 txt0_xp = chdev_dir.txt_tx[0]; 660 txt0_cxy = GET_CXY( txt0_xp ); 661 txt0_ptr = GET_PTR( txt0_xp ); 662 663 // get extended pointer on TXT0 lock 664 txt0_lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock ); 665 666 // get lock on local process list 667 remote_spinlock_lock( lock_xp ); 668 669 // get TXT0 lock in busy waiting mode 670 remote_spinlock_lock_busy( txt0_lock_xp , &txt0_save_sr ); 671 672 // display header 673 nolock_printk("\n***** processes in cluster %x / cycle %d\n", 674 cxy , (uint32_t)hal_get_cycles() ); 675 676 // loop on all processes in cluster cxy 594 677 XLIST_FOREACH( root_xp , iter_xp ) 595 678 { … … 597 680 process_display( process_xp ); 598 681 } 682 683 // release TXT0 lock in busy waiting mode 684 remote_spinlock_unlock_busy( txt0_lock_xp , txt0_save_sr ); 685 686 // release lock on local process list 687 remote_spinlock_unlock( lock_xp ); 688 599 689 } // end cluster_processes_display() 600 690 -
trunk/kernel/kern/cluster.h
r440 r443 61 61 * Warning : the "owner" cluster, and the "reference" cluster can be different clusters. 62 62 * 63 * The process manager of a cluster K maintains three structures: 64 * 1) The pref_tbl[] is an array indexed by lpid. There is one entry per owned process. 63 * The process manager of a cluster K maintains three sets of process descriptors: 64 * 65 * 1) pref_tbl[] is an array indexed by lpid. There is one entry per owned process. 65 66 * Each entry contains an extended pointer on the reference process descriptor. 66 67 * 67 * 2) The local_root is the root of the local list of process descriptors in cluster K.68 * 2) The local_root is the root of the local list of all process descriptors in cluster K. 68 69 * A process descriptor P is present in K, as soon as P has a thread in cluster K. 69 70 * … … 187 188 /****************************************************************************************** 188 189 * This function returns an extended pointer on the process descriptor in owner cluster 189 * from the process PID. This PID can be be different from the calling process PID.190 * from the process <pid>. This PID can be be different from the calling process PID. 190 191 * It can be called by any thread running in any cluster, 191 192 ****************************************************************************************** … … 197 198 /****************************************************************************************** 198 199 * This function returns an extended pointer on the reference process descriptor 199 * from the process PID. This PID can be be different from the calling process PID.200 * from the process <pid>. This PID can be be different from the calling process PID. 200 201 * It can be called by any thread running in any cluster, 201 202 ****************************************************************************************** … … 204 205 *****************************************************************************************/ 205 206 xptr_t cluster_get_reference_process_from_pid( pid_t pid ); 207 208 /****************************************************************************************** 209 * This function returns an extended pointer on the process descriptor copy for the 210 * process identified by <pid> in cluster defined by <cxy> argument. 211 * This PID can be be different from the calling process PID. 212 * It can be called by any thread running in any cluster, 213 ****************************************************************************************** 214 * @ cxy : target cluster identifier. 215 * @ pid : process identifier. 216 * @ return extended pointer on reference process if found / XPTR_NULL if not found. 217 *****************************************************************************************/ 218 xptr_t cluster_get_process_from_pid_in_cxy( cxy_t cxy, 219 pid_t pid ); 206 220 207 221 /****************************************************************************************** -
trunk/kernel/kern/core.c
r438 r443 49 49 core->usage = 0; 50 50 core->spurious_irqs = 0; 51 core->thread_idle = NULL;52 51 core->fpu_owner = NULL; 53 52 core->rand_last = hal_time_stamp() & 0xFFF; … … 90 89 void core_compute_stats( core_t * core ) 91 90 { 92 thread_t * idle = core-> thread_idle;91 thread_t * idle = core->scheduler.idle; 93 92 uint32_t ticks = core->ticks_nr; 94 93 … … 115 114 void core_reset_stats( core_t * core ) 116 115 { 117 core->ticks_nr = 0; 118 core->usage = 0; 119 core->thread_idle->ticks_nr = 0; 116 thread_t * idle = core->scheduler.idle; 117 118 core->ticks_nr = 0; 119 core->usage = 0; 120 idle->ticks_nr = 0; 121 120 122 hal_fence(); 121 123 } -
trunk/kernel/kern/core.h
r409 r443 57 57 uint32_t usage; /*! cumulated busy_percent (idle / total) */ 58 58 uint32_t spurious_irqs; /*! for instrumentation... */ 59 struct thread_s * thread_idle; /*! pointer on idle thread descriptor */60 59 struct thread_s * fpu_owner; /*! pointer on current FPU owner thread */ 61 60 uint32_t rand_last; /*! last computed random value */ -
trunk/kernel/kern/do_syscall.c
r438 r443 102 102 sys_trace, // 47 103 103 sys_fg, // 48 104 sys_undefined, // 49 104 105 }; 105 106 … … 136 137 else if( index == SYS_CLOSEDIR ) return "CLOSEDIR"; // 25 137 138 else if( index == SYS_GETCWD ) return "GETCWD"; // 26 139 else if( index == SYS_ISATTY ) return "ISATTY"; // 27 138 140 else if( index == SYS_ALARM ) return "ALARM"; // 28 139 141 else if( index == SYS_RMDIR ) return "RMDIR"; // 29 -
trunk/kernel/kern/kernel_init.c
r440 r443 59 59 #include <mapper.h> 60 60 61 #define KERNEL_INIT_SYNCHRO 0xA5A5B5B562 63 61 /////////////////////////////////////////////////////////////////////////////////////////// 64 62 // All the following global variables are replicated in all clusters. … … 912 910 913 911 #if( DEBUG_KERNEL_INIT & 1 ) 912 if( (core_lid == 0) & (local_cxy == 0) ) 914 913 chdev_dir_display(); 915 914 #endif … … 1179 1178 printk("\n[DBG] %s : exit barrier 8 : process init created / cycle %d\n", 1180 1179 __FUNCTION__ , (uint32_t)hal_get_cycles() ); 1180 #endif 1181 1182 #if (DEBUG_KERNEL_INIT & 1) 1183 if( (core_lid == 0) & (local_cxy == 0) ) 1184 sched_display( 0 ); 1181 1185 #endif 1182 1186 -
trunk/kernel/kern/printk.c
r437 r443 350 350 { 351 351 va_list args; 352 uint32_tsave_sr;352 reg_t save_sr; 353 353 354 354 // get pointers on TXT0 chdev -
trunk/kernel/kern/process.c
r441 r443 135 135 process->pid = pid; 136 136 process->ref_xp = XPTR( local_cxy , process ); 137 process->owner_xp = XPTR( local_cxy , process ); 137 138 process->parent_xp = parent_xp; 138 139 process->term_state = 0; … … 320 321 local_process->parent_xp = hal_remote_lwd( XPTR( ref_cxy , &ref_ptr->parent_xp ) ); 321 322 local_process->ref_xp = reference_process_xp; 323 local_process->owner_xp = reference_process_xp; 322 324 local_process->term_state = 0; 323 325 … … 409 411 cluster_process_copies_unlink( process ); 410 412 411 // remove process from children_list if process is inowner cluster413 // remove process from children_list if process owner cluster 412 414 if( CXY_FROM_PID( pid ) == local_cxy ) 413 415 { … … 426 428 } 427 429 428 // release the process PID to cluster manager if owner cluster430 // release the process PID to cluster manager if process owner cluster 429 431 if( CXY_FROM_PID( pid ) == local_cxy ) cluster_pid_release( pid ); 430 432 … … 800 802 // allocate memory for local process descriptor 801 803 process_ptr = process_alloc(); 804 802 805 if( process_ptr == NULL ) return NULL; 803 806 804 807 // initialize local process descriptor copy 805 808 error = process_copy_init( process_ptr , ref_xp ); 809 806 810 if( error ) return NULL; 807 811 } … … 1021 1025 } 1022 1026 1023 1024 1027 // release lock protecting th_tbl 1025 1028 hal_fence(); … … 1030 1033 } // end process_register_thread() 1031 1034 1032 /////////////////////////////////////////////// 1033 void process_remove_thread( thread_t * thread ) 1034 { 1035 ///////////////////////////////////////////////// 1036 bool_t process_remove_thread( thread_t * thread ) 1037 { 1038 uint32_t count; // number of threads in local process descriptor 1039 1035 1040 assert( (thread != NULL) , __FUNCTION__ , "thread argument is NULL" ); 1036 1041 … … 1043 1048 spinlock_lock( &process->th_lock ); 1044 1049 1045 assert( (process->th_nr) , __FUNCTION__ , "process th_nr cannot be 0\n" ); 1050 count = process->th_nr; 1051 1052 assert( (count > 0) , __FUNCTION__ , "process th_nr cannot be 0\n" ); 1046 1053 1047 1054 // remove thread from th_tbl[] … … 1049 1056 process->th_nr--; 1050 1057 1058 // release lock protecting th_tbl 1051 1059 hal_fence(); 1052 1053 // release lock protecting th_tbl1054 1060 spinlock_unlock( &process->th_lock ); 1061 1062 return (count == 1); 1055 1063 1056 1064 } // process_remove_thread() … … 1401 1409 process->pid = 0; 1402 1410 process->ref_xp = XPTR( local_cxy , process ); 1411 process->owner_xp = XPTR( local_cxy , process ); 1403 1412 process->parent_xp = XPTR_NULL; 1404 1413 process->term_state = 0; … … 1531 1540 process_t * process_ptr; 1532 1541 cxy_t process_cxy; 1542 1533 1543 xptr_t parent_xp; // extended pointer on parent process 1534 1544 process_t * parent_ptr; 1535 1545 cxy_t parent_cxy; 1536 1546 1547 xptr_t owner_xp; // extended pointer on owner process 1548 process_t * owner_ptr; 1549 cxy_t owner_cxy; 1550 1537 1551 pid_t pid; 1538 1552 pid_t ppid; 1539 1553 uint32_t state; 1540 xptr_t ref_xp;1541 1554 uint32_t th_nr; 1542 1555 1543 xptr_t txt_file_xp; // extended pointer on TXT_RX pseudo file1544 xptr_t chdev_xp;// extended pointer on TXT_RX chdev1545 chdev_t * chdev_ptr;1546 cxy_t chdev_cxy;1547 xptr_t owner_xp;// extended pointer on TXT owner process1556 xptr_t txt_file_xp; // extended pointer on TXT_RX file descriptor 1557 xptr_t txt_chdev_xp; // extended pointer on TXT_RX chdev 1558 chdev_t * txt_chdev_ptr; 1559 cxy_t txt_chdev_cxy; 1560 xptr_t txt_owner_xp; // extended pointer on TXT owner process 1548 1561 1549 1562 xptr_t elf_file_xp; // extended pointer on .elf file … … 1558 1571 process_ptr = GET_PTR( process_xp ); 1559 1572 process_cxy = GET_CXY( process_xp ); 1560 1561 // check reference process1562 ref_xp = hal_remote_lwd( XPTR( process_cxy , &process_ptr->ref_xp ) );1563 assert( (process_xp == ref_xp) , __FUNCTION__ , "process is not the reference\n");1564 1573 1565 1574 // get PID and state … … 1576 1585 th_nr = hal_remote_lw( XPTR( process_cxy , &process_ptr->th_nr ) ); 1577 1586 1578 // get TXT name and process owner 1579 txt_file_xp = hal_remote_lwd( XPTR( process_cxy , &process_ptr->fd_array.array[0] ) ); 1587 // get pointers on owner process descriptor 1588 owner_xp = hal_remote_lwd( XPTR( process_cxy , &process_ptr->owner_xp ) ); 1589 owner_cxy = GET_CXY( owner_xp ); 1590 owner_ptr = GET_PTR( owner_xp ); 1591 1592 // get extended pointer on TXT_RX file descriptor attached to process 1593 txt_file_xp = hal_remote_lwd( XPTR( owner_cxy , &owner_ptr->fd_array.array[0] ) ); 1580 1594 1581 1595 assert( (txt_file_xp != XPTR_NULL) , __FUNCTION__ , 1582 1596 "process must be attached to one TXT terminal\n" ); 1583 1597 1584 chdev_xp = chdev_from_file( txt_file_xp ); 1585 chdev_cxy = GET_CXY( chdev_xp ); 1586 chdev_ptr = (chdev_t *)GET_PTR( chdev_xp ); 1598 // get TXT_RX chdev pointers 1599 txt_chdev_xp = chdev_from_file( txt_file_xp ); 1600 txt_chdev_cxy = GET_CXY( txt_chdev_xp ); 1601 txt_chdev_ptr = GET_PTR( txt_chdev_xp ); 1602 1603 // get TXT_RX name and ownership 1587 1604 hal_remote_strcpy( XPTR( local_cxy , txt_name ) , 1588 XPTR( chdev_cxy , chdev_ptr->name ) ); 1589 owner_xp = (xptr_t)hal_remote_lwd( XPTR( chdev_cxy , &chdev_ptr->ext.txt.owner_xp ) ); 1605 XPTR( txt_chdev_cxy , txt_chdev_ptr->name ) ); 1606 1607 txt_owner_xp = (xptr_t)hal_remote_lwd( XPTR( txt_chdev_cxy, 1608 &txt_chdev_ptr->ext.txt.owner_xp ) ); 1590 1609 1591 1610 // get process .elf name 1592 1611 elf_file_xp = hal_remote_lwd( XPTR( process_cxy , &process_ptr->vfs_bin_xp ) ); 1593 1594 1612 elf_file_cxy = GET_CXY( elf_file_xp ); 1595 1613 elf_file_ptr = (vfs_file_t *)GET_PTR( elf_file_xp ); … … 1598 1616 1599 1617 // display process info 1600 if( owner_xp == process_xp )1601 { 1602 printk("PID %X | PPID %X | STS %X | %s (FG) | %X | %d | %s\n",1618 if( txt_owner_xp == process_xp ) 1619 { 1620 nolock_printk("PID %X | PPID %X | STS %X | %s (FG) | %X | %d | %s\n", 1603 1621 pid, ppid, state, txt_name, process_ptr, th_nr, elf_name ); 1604 1622 } 1605 1623 else 1606 1624 { 1607 printk("PID %X | PPID %X | STS %X | %s (BG) | %X | %d | %s\n",1625 nolock_printk("PID %X | PPID %X | STS %X | %s (BG) | %X | %d | %s\n", 1608 1626 pid, ppid, state, txt_name, process_ptr, th_nr, elf_name ); 1609 1627 } … … 1988 2006 xptr_t current_xp; 1989 2007 xptr_t iter_xp; 1990 1991 // check terminal index 2008 cxy_t txt0_cxy; 2009 chdev_t * txt0_ptr; 2010 xptr_t txt0_xp; 2011 xptr_t txt0_lock_xp; 2012 reg_t txt0_save_sr; // save SR to take TXT0 lock in busy mode 2013 1992 2014 assert( (txt_id < LOCAL_CLUSTER->nb_txt_channels) , 1993 2015 __FUNCTION__ , "illegal TXT terminal index" ); 2016 2017 // get pointers on TXT0 chdev 2018 txt0_xp = chdev_dir.txt_tx[0]; 2019 txt0_cxy = GET_CXY( txt0_xp ); 2020 txt0_ptr = GET_PTR( txt0_xp ); 2021 2022 // get extended pointer on TXT0 lock 2023 txt0_lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock ); 1994 2024 1995 2025 // get pointers on TXT_RX[txt_id] chdev … … 2002 2032 lock_xp = XPTR( chdev_cxy , &chdev_ptr->ext.txt.lock ); 2003 2033 2034 // get lock on attached process list 2035 remote_spinlock_lock( lock_xp ); 2036 2037 // get TXT0 lock in busy waiting mode 2038 remote_spinlock_lock_busy( txt0_lock_xp , &txt0_save_sr ); 2039 2004 2040 // display header 2005 printk("\n***** processes attached to TXT_%d\n", txt_id ); 2006 2007 // get lock 2008 remote_spinlock_lock( lock_xp ); 2041 nolock_printk("\n***** processes attached to TXT_%d / cycle %d\n", 2042 txt_id , (uint32_t)hal_get_cycles() ); 2009 2043 2010 2044 // scan attached process list … … 2015 2049 } 2016 2050 2017 // release lock 2051 // release TXT0 lock in busy waiting mode 2052 remote_spinlock_unlock_busy( txt0_lock_xp , txt0_save_sr ); 2053 2054 // release lock on attached process list 2018 2055 remote_spinlock_unlock( lock_xp ); 2019 2056 -
trunk/kernel/kern/process.h
r441 r443 90 90 * The process descriptor is replicated in all clusters containing at least one thread 91 91 * of the PID process, with the following rules : 92 * 1) The <pid>, <ppid>, <ref_xp>, < vfs_root_xp>, <vfs_bin_xp> fields are defined93 * in all process descriptor copies.92 * 1) The <pid>, <ppid>, <ref_xp>, <owner_xp>, <vfs_root_xp>, <vfs_bin_xp> fields are 93 * defined in all process descriptor copies. 94 94 * 2) The <vfs_cwd_xp> and associated <cwd_lock>, that can be dynamically modified, 95 95 * are only defined in the reference process descriptor. … … 106 106 * are defined in all process descriptors copies. 107 107 * 7) The termination <flags> and <exit_status> are only defined in the reference cluster. 108 * The term 108 * The term_state format is defined in the shared_syscalls.h file. 109 109 ********************************************************************************************/ 110 110 … … 119 119 pid_t pid; /*! process identifier */ 120 120 xptr_t ref_xp; /*! extended pointer on reference process */ 121 xptr_t owner_xp; /*! extended pointer on owner process */ 121 122 xptr_t parent_xp; /*! extended pointer on parent process */ 122 123 … … 264 265 /********************************************************************************************* 265 266 * This debug function diplays on the kernel terminal TXT0 detailed informations on a 266 * reference processidentified by the <process_xp> argument.267 * process descriptor identified by the <process_xp> argument. 267 268 * It can be called by a thread running in any cluster. 268 ********************************************************************************************* 269 * @ process_xp : extended pointer on reference process. 269 * WARNING: this function uses the nolock_printk() function, and the TXT0 lock MUST be 270 * taken by the caller function. 271 ********************************************************************************************* 272 * @ process_xp : extended pointer on process descriptor. 270 273 ********************************************************************************************/ 271 274 void process_display( xptr_t process_xp ); … … 379 382 380 383 /********************************************************************************************* 381 * This function implements the "fork" system call, and is called by the sys_fork() function .382 * It allocates memory and initializes a new "child" process descriptor, and the383 * associated "child" thread descriptor in the local cluster. This function can involve384 * up to three different clusters :385 * - the child (local) cluster can be any cluster defined by the sys_fork function.384 * This function implements the "fork" system call, and is called by the sys_fork() function, 385 * likely throuch the RPC_PROCESS_MAKE_FORK. 386 * It allocates memory and initializes a new "child" process descriptor, and the associated 387 * "child" thread descriptor in local cluster. It involves up to three different clusters : 388 * - the child (local) cluster can be any cluster selected by the sys_fork function. 386 389 * - the parent cluster must be the reference cluster for the parent process. 387 390 * - the client cluster containing the thread requesting the fork can be any cluster. … … 483 486 * It checks that there is an available slot in the local th_tbl[] array, 484 487 * allocates a new LTID, and registers the new thread in the th_tbl[]. 485 * WARNING : the lock protecting the th_tbl[] must be taken by the caller.488 * It takes the lock protecting exclusive access to the th_tbl[]. 486 489 ********************************************************************************************* 487 490 * @ process : pointer on the local process descriptor. … … 496 499 /********************************************************************************************* 497 500 * This function removes a thread registration from the local process descriptor. 498 * WARNING : the lock protecting the th_tbl[] must be taken by the caller.501 * It takes the lock protecting exclusive access to the th_tbl[]. 499 502 ********************************************************************************************* 500 503 * @ thread : local pointer on thread to be removed. 501 ********************************************************************************************/ 502 void process_remove_thread( struct thread_s * thread ); 504 * @ return true if the removed thread was the last registered thread. 505 ********************************************************************************************/ 506 bool_t process_remove_thread( struct thread_s * thread ); 503 507 504 508 … … 551 555 * When the process dentified by the <owner_xp> argument has the exclusive ownership of 552 556 * the TXT_RX terminal, this function transfer this ownership to another attached process. 553 * The process descriptor must be in the process owner cluster. 554 * This function does nothing if the <pid> process is not the owner. 557 * The process descriptor must be the process owner. 558 * This function does nothing if the process identified by the <process_xp> is not 559 * the TXT owner. 555 560 * - If the current owner is not the KSH process, the new owner is the KSH process. 556 * - If the <pid> process is thethe KSH process, the new owner is another attached process.561 * - If the current owner is the KSH process, the new owner is another attached process. 557 562 * - If there is no other attached process, the TXT has no more defined owner. 558 563 ********************************************************************************************* -
trunk/kernel/kern/scheduler.c
r440 r443 34 34 #include <scheduler.h> 35 35 36 36 37 /////////////////////////////////////////////////////////////////////////////////////////// 37 38 // Extern global variables 38 39 /////////////////////////////////////////////////////////////////////////////////////////// 39 40 40 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c file 41 extern uint32_t switch_save_sr[]; // allocated in kernel_init.c file 41 uint32_t idle_thread_count; 42 uint32_t idle_thread_count_active; 43 44 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c file 45 extern uint32_t switch_save_sr[]; // allocated in kernel_init.c file 42 46 43 47 //////////////////////////////// … … 50 54 51 55 sched->current = CURRENT_THREAD; 52 sched->idle = NULL; // initialized in kernel_init()53 sched->u_last = NULL; // initialized in sched_register_thread()54 sched->k_last = NULL; // initialized in sched_register_thread()56 sched->idle = NULL; // initialized in kernel_init() 57 sched->u_last = NULL; // initialized in sched_register_thread() 58 sched->k_last = NULL; // initialized in sched_register_thread() 55 59 56 60 // initialise threads lists … … 58 62 list_root_init( &sched->k_root ); 59 63 60 sched->req_ack_pending = false; // no pending request 64 sched->req_ack_pending = false; // no pending request 65 sched->trace = false; // context switches trace desactivated 61 66 62 67 } // end sched_init() … … 179 184 thread_t * thread; 180 185 process_t * process; 186 bool_t last_thread; 181 187 182 188 // get pointer on scheduler … … 237 243 238 244 // delete thread 239 thread_destroy( thread );245 last_thread = thread_destroy( thread ); 240 246 241 247 #if DEBUG_SCHED_HANDLE_SIGNALS 242 248 uint32_t cycle = (uint32_t)hal_get_cycles(); 243 249 if( DEBUG_SCHED_HANDLE_SIGNALS < cycle ) 244 printk("\n[DBG] %s : thread %x in proces %x (%x)deleted / cycle %d\n",245 __FUNCTION__ , thread , process->pid , process, cycle );250 printk("\n[DBG] %s : thread %x in proces %x on core[%x,%d] deleted / cycle %d\n", 251 __FUNCTION__ , thread->trdid , process->pid , local_cxy , thread->core->lid , cycle ); 246 252 #endif 247 253 // destroy process descriptor if no more threads 248 if( process->th_nr == 0)254 if( last_thread ) 249 255 { 250 256 // delete process … … 254 260 cycle = (uint32_t)hal_get_cycles(); 255 261 if( DEBUG_SCHED_HANDLE_SIGNALS < cycle ) 256 printk("\n[DBG] %s : process %x has beendeleted / cycle %d\n",257 __FUNCTION__ , process->pid , cycle );262 printk("\n[DBG] %s : process %x in cluster %x deleted / cycle %d\n", 263 __FUNCTION__ , process->pid , local_cxy , cycle ); 258 264 #endif 259 265 … … 277 283 278 284 #if (DEBUG_SCHED_YIELD & 0x1) 279 if( DEBUG_SCHED_YIELD < (uint32_t)hal_get_cycles())285 if( sched->trace ) 280 286 sched_display( core->lid ); 281 287 #endif … … 295 301 296 302 // check next thread kernel_stack overflow 297 assert( (next->signature == THREAD_SIGNATURE), 298 __FUNCTION__ , "kernel stack overflow for thread %x\n", next);303 assert( (next->signature == THREAD_SIGNATURE), __FUNCTION__ , 304 "kernel stack overflow for thread %x on core[%x,%d] \n", next, local_cxy, core->lid ); 299 305 300 306 // check next thread attached to same core as the calling thread 301 assert( (next->core == current->core), 302 __FUNCTION__ ,"next core %x != current core %x\n", next->core, current->core );307 assert( (next->core == current->core), __FUNCTION__ , 308 "next core %x != current core %x\n", next->core, current->core ); 303 309 304 310 // check next thread not blocked when type != IDLE … … 311 317 { 312 318 313 if( (local_cxy == 0X1) && (core->lid == 1) && ((uint32_t)current == 0xcc000) )314 printk("\n@@@@@ cc000 exit at cycle %d\n", (uint32_t)hal_get_cycles() );315 316 if( (local_cxy == 0X1) && (core->lid == 1) && ((uint32_t)next == 0xcc000) )317 printk("\n@@@@@ cc000 enter at cycle %d\n", (uint32_t)hal_get_cycles() );318 319 319 #if DEBUG_SCHED_YIELD 320 uint32_t cycle = (uint32_t)hal_get_cycles(); 321 if( DEBUG_SCHED_YIELD < cycle ) 320 if( sched->trace ) 322 321 printk("\n[DBG] %s : core[%x,%d] / cause = %s\n" 323 322 " thread %x (%s) (%x,%x) => thread %x (%s) (%x,%x) / cycle %d\n", 324 323 __FUNCTION__, local_cxy, core->lid, cause, 325 current, thread_type_str(current->type), current->process->pid, current->trdid, 326 next , thread_type_str(next->type) , next->process->pid , next->trdid , cycle);324 current, thread_type_str(current->type), current->process->pid, current->trdid,next , 325 thread_type_str(next->type) , next->process->pid , next->trdid , (uint32_t)hal_get_cycles() ); 327 326 #endif 328 327 … … 345 344 { 346 345 347 #if (DEBUG_SCHED_YIELD & 1) 348 uint32_t cycle = (uint32_t)hal_get_cycles(); 349 if( DEBUG_SCHED_YIELD < cycle ) 346 #if DEBUG_SCHED_YIELD 347 if( sched->trace ) 350 348 printk("\n[DBG] %s : core[%x,%d] / cause = %s\n" 351 349 " thread %x (%s) (%x,%x) continue / cycle %d\n", 352 __FUNCTION__, local_cxy, core->lid, cause, 353 current , thread_type_str(current->type), current->process->pid, current->trdid, cycle);350 __FUNCTION__, local_cxy, core->lid, cause, current, thread_type_str(current->type), 351 current->process->pid, current->trdid, (uint32_t)hal_get_cycles() ); 354 352 #endif 355 353 … … 389 387 390 388 nolock_printk("\n***** threads on core[%x,%d] / current %x / cycle %d\n", 391 389 local_cxy , core->lid, sched->current, (uint32_t)hal_get_cycles() ); 392 390 393 391 // display kernel threads -
trunk/kernel/kern/scheduler.h
r437 r443 50 50 struct thread_s * current; /*! pointer on current running thread */ 51 51 volatile bool_t req_ack_pending; /*! sequencialize ack requests when true */ 52 bool_t trace; /*! context switches trace activated if true */ 52 53 } 53 54 scheduler_t; -
trunk/kernel/kern/thread.c
r440 r443 142 142 cluster_t * local_cluster = LOCAL_CLUSTER; 143 143 144 #if DEBUG_THREAD_USER_INIT 145 uint32_t cycle = (uint32_t)hal_get_cycles(); 146 if( DEBUG_THREAD_USER_INIT < cycle ) 147 printk("\n[DBG] %s : thread %x enter to init thread %x in process %x / cycle %d\n", 148 __FUNCTION__, CURRENT_THREAD, thread, process->pid , cycle ); 149 #endif 150 144 151 // register new thread in process descriptor, and get a TRDID 145 152 error = process_register_thread( process, thread , &trdid ); … … 196 203 thread->signature = THREAD_SIGNATURE; 197 204 198 // FIXME call hal_thread_init() function to initialise the save_sr field 205 // FIXME define and call an architecture specific hal_thread_init() 206 // function to initialise the save_sr field 199 207 thread->save_sr = 0xFF13; 200 208 … … 204 212 // update DQDT 205 213 dqdt_update_threads( 1 ); 214 215 #if DEBUG_THREAD_USER_INIT 216 cycle = (uint32_t)hal_get_cycles(); 217 if( DEBUG_THREAD_USER_INIT < cycle ) 218 printk("\n[DBG] %s : thread %x exit after init of thread %x in process %x / cycle %d\n", 219 __FUNCTION__, CURRENT_THREAD, thread, process->pid , cycle ); 220 #endif 206 221 207 222 return 0; … … 227 242 uint32_t cycle = (uint32_t)hal_get_cycles(); 228 243 if( DEBUG_THREAD_USER_CREATE < cycle ) 229 printk("\n[DBG] %s : thread %x enter / process%x / cycle %d\n",230 __FUNCTION__, CURRENT_THREAD, pid , cycle );244 printk("\n[DBG] %s : thread %x enter for process %x in cluster %x / cycle %d\n", 245 __FUNCTION__, CURRENT_THREAD, pid , local_cxy , cycle ); 231 246 #endif 232 247 … … 240 255 return ENOMEM; 241 256 } 257 258 #if( DEBUG_THREAD_USER_CREATE & 1) 259 if( DEBUG_THREAD_USER_CREATE < cycle ) 260 printk("\n[DBG] %s : process descriptor = %x for process %x in cluster %x\n", 261 __FUNCTION__, process , pid , local_cxy ); 262 #endif 242 263 243 264 // select a target core in local cluster … … 256 277 core_lid = cluster_select_local_core(); 257 278 } 279 280 #if( DEBUG_THREAD_USER_CREATE & 1) 281 if( DEBUG_THREAD_USER_CREATE < cycle ) 282 printk("\n[DBG] %s : core[%x,%d] selected\n", 283 __FUNCTION__, local_cxy , core_lid ); 284 #endif 258 285 259 286 // allocate a stack from local VMM … … 282 309 return ENOMEM; 283 310 } 311 312 #if( DEBUG_THREAD_USER_CREATE & 1) 313 if( DEBUG_THREAD_USER_CREATE < cycle ) 314 printk("\n[DBG] %s : thread descriptor %x allocated\n", 315 __FUNCTION__, thread ); 316 #endif 284 317 285 318 // initialize thread descriptor … … 300 333 } 301 334 335 #if( DEBUG_THREAD_USER_CREATE & 1) 336 if( DEBUG_THREAD_USER_CREATE < cycle ) 337 printk("\n[DBG] %s : thread descriptor %x initialised / trdid = %x\n", 338 __FUNCTION__, thread , thread->trdid ); 339 #endif 340 302 341 // set DETACHED flag if required 303 342 if( attr->attributes & PT_ATTR_DETACH ) … … 327 366 cycle = (uint32_t)hal_get_cycles(); 328 367 if( DEBUG_THREAD_USER_CREATE < cycle ) 329 printk("\n[DBG] %s : thread %x exit / process %x / new_thread%x / core %d / cycle %d\n",330 __FUNCTION__, CURRENT_THREAD, pid, thread, core_lid, cycle );368 printk("\n[DBG] %s : thread %x exit / new_thread %x in process %x / core %d / cycle %d\n", 369 __FUNCTION__, CURRENT_THREAD, thread->trdid , pid , core_lid, cycle ); 331 370 #endif 332 371 … … 602 641 // has been released, using a cache of mmap requests. [AG] 603 642 /////////////////////////////////////////////////////////////////////////////////////// 604 voidthread_destroy( thread_t * thread )643 bool_t thread_destroy( thread_t * thread ) 605 644 { 606 645 reg_t save_sr; 646 bool_t last_thread; 607 647 608 648 process_t * process = thread->process; … … 616 656 #endif 617 657 618 assert( (thread->local_locks == 0) , __FUNCTION__ , "all local locks not released" ); 619 620 assert( (thread->remote_locks == 0) , __FUNCTION__ , "all remote locks not released" ); 658 assert( (thread->local_locks == 0) , __FUNCTION__ , 659 "local lock not released for thread %x in process %x", thread->trdid, process->pid ); 660 661 assert( (thread->remote_locks == 0) , __FUNCTION__ , 662 "remote lock not released for thread %x in process %x", thread->trdid, process->pid ); 621 663 622 664 // update intrumentation values … … 637 679 638 680 // remove thread from process th_tbl[] 639 process_remove_thread( thread );681 last_thread = process_remove_thread( thread ); 640 682 641 683 // update DQDT … … 654 696 __FUNCTION__, CURRENT_THREAD, thread, process->pid, cycle ); 655 697 #endif 698 699 return last_thread; 656 700 657 701 } // end thread_destroy() … … 1092 1136 hal_enable_irq( NULL ); 1093 1137 1094 if( CONFIG_THREAD_IDLE_MODE_SLEEP ) // force core to low-power mode 1138 // force core to low-power mode (optional) 1139 if( CONFIG_THREAD_IDLE_MODE_SLEEP ) 1095 1140 { 1096 1141 … … 1113 1158 1114 1159 } 1115 else // search a runable thread 1116 { 1117 sched_yield( "IDLE" ); 1118 } 1160 1161 // search a runable thread 1162 sched_yield( "IDLE" ); 1119 1163 } 1120 1164 } // end thread_idle() -
trunk/kernel/kern/thread.h
r440 r443 77 77 78 78 /*************************************************************************************** 79 * This defines the masks associated to the blocking causes.79 * This defines the thread blocking causes bit-vector. 80 80 **************************************************************************************/ 81 81 … … 278 278 279 279 /*************************************************************************************** 280 * This function is called by the kernel_init() function to initialize the IDLE thread .281 * It initializes an existing threaddescriptor from arguments values.280 * This function is called by the kernel_init() function to initialize the IDLE thread 281 * descriptor from arguments values. 282 282 * The THREAD_BLOCKED_GLOBAL bit is set, and the thread must be activated to start. 283 283 *************************************************************************************** … … 296 296 297 297 /*************************************************************************************** 298 * This function releases the physical memory allocated for a thread in a given cluster. 299 * This include the thread descriptor itself, the associated CPU and FPU context, and 300 * the physical memory allocated for an user thread local stack. 298 * This function is called by the sched_handle_signals() function to releases 299 * the physical memory allocated for a thread in a given cluster, when this thread 300 * is marked for delete. This include the thread descriptor itself, the associated 301 * CPU and FPU context, and the physical memory allocated for an user thread local stack. 302 * The destroyed thread is removed from the local process th_tbl[] array, and returns 303 * true when the destroyed thread was the last thread registered in process. 301 304 *************************************************************************************** 302 305 * @ thread : pointer on the thread descriptor to release. 303 **************************************************************************************/ 304 void thread_destroy( thread_t * thread ); 306 * @ return true, if the thread was the last registerd thread in local process. 307 **************************************************************************************/ 308 bool_t thread_destroy( thread_t * thread ); 305 309 306 310 /*************************************************************************************** 307 311 * This function defines the code of the thread executed by all cores after kernel_init, 308 312 * or when no other thread is runnable for a given core. 309 * 310 * TODO: In the TSAR architecture, it enters an infinite loop, in wich it forces 311 * the core in sleep (low-power) mode. Any IRQ will force the core to exit this sleep 312 * mode, but no ISR is executed. 313 * TODO: We must analyse if we have the same behaviour for I86 architectures... 313 * It enter and infinite loop in wich: 314 * - it unmask the IRQs 315 * - it optionally calls the hal_core_sleep() function to reduce the power consumption 316 * (this behavior is controlled by the CONFIG_THREAD_IDLE_MODE_SLEEP flag). 317 * - it call the sched_yield() function to find another runnable thread. 318 * 319 * TODO: In the TSAR architecture the hal_core_sleep() function forces the core to 320 * low-power mode. Any IRQ will force the core to exit this low-power mode, but no ISR 321 * is executed. We must analyse if we have the same behaviour for I86 architectures... 314 322 **************************************************************************************/ 315 323 void thread_idle_func(); … … 357 365 /*************************************************************************************** 358 366 * This function is used by the four sys_thread_cancel(), sys_thread_exit(), 359 * sys_kill() and sys_exit() system calls to delete a given thread.367 * sys_kill() and sys_exit() system calls to mark for delete a given thread. 360 368 * It set the THREAD_BLOCKED_GLOBAL bit and set the the THREAD_FLAG_REQ_DELETE bit 361 369 * in the thread descriptor identified by the <thread_xp> argument, to ask the scheduler -
trunk/kernel/kernel_config.h
r441 r443 67 67 #define DEBUG_FATFS_LOAD 0 68 68 69 #define DEBUG_GPT_ACCESS 0 69 #define DEBUG_HAL_GPT_ACCESS 0 70 #define DEBUG_HAL_GPT_CREATE 0 71 #define DEBUG_HAL_GPT_DESTROY 0 70 72 71 73 #define DEBUG_HAL_KENTRY 0 … … 76 78 #define DEBUG_HAL_IOC_RX 0 77 79 #define DEBUG_HAL_IOC_TX 0 80 #define DEBUG_HAL_GPT 78 81 79 82 #define DEBUG_KCM 0 … … 115 118 #define DEBUG_RPC_VMM_GET_VSEG 0 116 119 117 #define DEBUG_SCHED_HANDLE_SIGNALS 0118 #define DEBUG_SCHED_YIELD 0120 #define DEBUG_SCHED_HANDLE_SIGNALS 2 121 #define DEBUG_SCHED_YIELD 2 // dynamically activated by the trace() syscall 119 122 120 123 #define DEBUG_SYSCALLS_ERROR 2 … … 132 135 #define DEBUG_SYS_THREAD_CANCEL 0 133 136 #define DEBUG_SYS_THREAD_CREATE 0 134 #define DEBUG_SYS_THREAD_EXIT 1137 #define DEBUG_SYS_THREAD_EXIT 0 135 138 #define DEBUG_SYS_THREAD_JOIN 0 136 139 #define DEBUG_SYS_THREAD_SLEEP 0 137 140 #define DEBUG_SYS_THREAD_WAKEUP 0 141 #define DEBUG_SYS_TRACE 0 138 142 #define DEBUG_SYS_WAIT 0 139 143 #define DEBUG_SYS_WRITE 0 … … 146 150 #define DEBUG_THREAD_DESTROY 0 147 151 #define DEBUG_THREAD_IDLE 0 152 #define DEBUG_THREAD_INIT 0 148 153 #define DEBUG_THREAD_KERNEL_CREATE 0 149 154 #define DEBUG_THREAD_KILL 0 … … 199 204 200 205 #define CONFIG_TXT_ECHO_MODE 1 // echo mode for TXT peripheral 201 #define CONFIG_TXT_KBUF_SIZE 256// kernel buffer for TXT write206 #define CONFIG_TXT_KBUF_SIZE 512 // kernel buffer for TXT write 202 207 203 208 #define CONFIG_FBF_WIDTH 128 … … 265 270 #define CONFIG_THREAD_DESC_SIZE 0x4000 // thread desc size (with kernel stack) 266 271 #define CONFIG_THREAD_DESC_ORDER 2 // ln( number of 4K pages ) 267 #define CONFIG_THREAD_IDLE_MODE_SLEEP 0// idle thread enter sleep mode272 #define CONFIG_THREAD_IDLE_MODE_SLEEP false // idle thread enter sleep mode 268 273 269 274 //////////////////////////////////////////////////////////////////////////////////////////// -
trunk/kernel/libk/remote_spinlock.c
r438 r443 201 201 xlist_add_first( XPTR( local_cxy , &thread_ptr->xlocks_root ), 202 202 XPTR( lock_cxy , &lock_ptr->list ) ); 203 204 // if( (uint32_t)lock_ptr == 0x66788 )205 // printk("\n@@@ %s : thread %x takes remote_spinlock %x\n",206 //__FUNCTION__, thread_ptr, lock_ptr );207 208 203 #endif 209 204 … … 225 220 hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) , XPTR_NULL ); 226 221 xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) ); 227 228 // if( (uint32_t)lock_ptr == 0x66788 )229 // printk("\n@@@ %s : thread %x releases remote_spinlock %x\n",230 // __FUNCTION__, thread_ptr, lock_ptr );231 232 222 #endif 233 223 -
trunk/kernel/mm/vmm.c
r441 r443 201 201 gpt_t * gpt = &vmm->gpt; 202 202 203 printk("\n***** VSL and GPT for process %x in cluster %x\n\n", 204 process->pid , local_cxy ); 203 printk("\n***** VSL and GPT for process %x in cluster %x\n\n", process->pid , local_cxy ); 205 204 206 205 // get lock protecting the vseg list … … 666 665 uint32_t cycle = (uint32_t)hal_get_cycles(); 667 666 if( DEBUG_VMM_DESTROY < cycle ) 668 printk("\n[DBG] %s : thread %x enter for process %x / cycle %d\n",669 __FUNCTION__ , CURRENT_THREAD , process->pid , cycle );667 printk("\n[DBG] %s : thread %x enter for process %x in cluster %x / cycle %d\n", 668 __FUNCTION__ , CURRENT_THREAD , process->pid , local_cxy , cycle ); 670 669 #endif 671 670 672 671 #if (DEBUG_VMM_DESTROY & 1 ) 672 if( DEBUG_VMM_DESTROY < cycle ) 673 673 vmm_display( process , true ); 674 674 #endif … … 693 693 #if( DEBUG_VMM_DESTROY & 1 ) 694 694 if( DEBUG_VMM_DESTROY < cycle ) 695 printk("\n[DBG] %s : %s/ vpn_base %x / vpn_size %d\n",695 printk("\n[DBG] %s : found %s vseg / vpn_base %x / vpn_size %d\n", 696 696 __FUNCTION__ , vseg_type_str( vseg->type ), vseg->vpn_base, vseg->vpn_size ); 697 697 #endif 698 699 698 // unmap and release physical pages 700 699 vmm_unmap_vseg( process , vseg ); … … 705 704 // release memory allocated to vseg descriptor 706 705 vseg_free( vseg ); 706 707 #if( DEBUG_VMM_DESTROY & 1 ) 708 if( DEBUG_VMM_DESTROY < cycle ) 709 printk("\n[DBG] %s : %s vseg released / vpn_base %x / vpn_size %d\n", 710 __FUNCTION__ , vseg_type_str( vseg->type ), vseg->vpn_base, vseg->vpn_size ); 711 #endif 712 707 713 } 708 714 … … 717 723 { 718 724 vseg = LIST_FIRST( &vmm->mmap_mgr.zombi_list[i] , vseg_t , zlist ); 725 726 #if( DEBUG_VMM_DESTROY & 1 ) 727 if( DEBUG_VMM_DESTROY < cycle ) 728 printk("\n[DBG] %s : found zombi vseg / vpn_base %x / vpn_size %d\n", 729 __FUNCTION__ , vseg_type_str( vseg->type ), vseg->vpn_base, vseg->vpn_size ); 730 #endif 719 731 vseg_detach( vmm , vseg ); 720 732 vseg_free( vseg ); 733 734 #if( DEBUG_VMM_DESTROY & 1 ) 735 if( DEBUG_VMM_DESTROY < cycle ) 736 printk("\n[DBG] %s : zombi vseg released / vpn_base %x / vpn_size %d\n", 737 __FUNCTION__ , vseg_type_str( vseg->type ), vseg->vpn_base, vseg->vpn_size ); 738 #endif 721 739 } 722 740 } … … 728 746 cycle = (uint32_t)hal_get_cycles(); 729 747 if( DEBUG_VMM_DESTROY < cycle ) 730 printk("\n[DBG] %s : thread %x exit / cycle %d\n",731 __FUNCTION__ , CURRENT_THREAD , cycle );748 printk("\n[DBG] %s : thread %x exit for process %x in cluster %x / cycle %d\n", 749 __FUNCTION__ , CURRENT_THREAD , process->pid , local_cxy , cycle ); 732 750 #endif 733 751 -
trunk/kernel/syscalls/sys_display.c
r440 r443 30 30 #include <process.h> 31 31 #include <string.h> 32 32 #include <shared_syscalls.h> 33 34 ///////////////////////////////////////////////////////////////////////////////// 35 // This static function returns a printable string for the type of display. 36 ///////////////////////////////////////////////////////////////////////////////// 37 38 #if DEBUG_SYS_DISPLAY 39 static char* display_type_str( uint32_t type ) 40 { 41 if ( type == DISPLAY_STRING ) return "STRING"; 42 else if( type == DISPLAY_VMM ) return "VMM"; 43 else if( type == DISPLAY_SCHED ) return "SCHED"; 44 else if( type == DISPLAY_CLUSTER_PROCESSES ) return "CLUSTER_PROCESSES"; 45 else if( type == DISPLAY_VFS ) return "VFS"; 46 else if( type == DISPLAY_CHDEV ) return "CHDEV"; 47 else if( type == DISPLAY_TXT_PROCESSES ) return "TXT_PROCESSES"; 48 } 49 #endif 33 50 34 51 ///////////////////////////// … … 49 66 tm_start = hal_get_cycles(); 50 67 if( DEBUG_SYS_DISPLAY < tm_start ) 51 printk("\n[DBG] %s : thread %d enter / process %x / type % d/ cycle = %d\n",52 __FUNCTION__, this, this->process->pid, type, (uint32_t)tm_start );68 printk("\n[DBG] %s : thread %d enter / process %x / type %s / cycle = %d\n", 69 __FUNCTION__, this, this->process->pid, display_type_str(type), (uint32_t)tm_start ); 53 70 #endif 54 71 … … 98 115 else if( type == DISPLAY_VMM ) 99 116 { 100 pid_t pid = (pid_t)arg0; 101 102 // get extended pointer on reference process 103 xptr_t process_xp = cluster_get_reference_process_from_pid( pid ); 117 cxy_t cxy = (cxy_t)arg0; 118 pid_t pid = (pid_t)arg1; 119 120 // check cxy argument 121 if( cluster_is_undefined( cxy ) ) 122 { 123 124 #if DEBUG_SYSCALLS_ERROR 125 printk("\n[ERROR] in %s : illegal cxy argument %x / thread %x / process %x\n", 126 __FUNCTION__ , cxy , this->trdid , process->pid ); 127 #endif 128 this->errno = EINVAL; 129 return -1; 130 } 131 132 // get extended pointer on process PID in cluster CXY 133 xptr_t process_xp = cluster_get_process_from_pid_in_cxy( cxy , pid ); 104 134 105 135 if( process_xp == XPTR_NULL ) … … 107 137 108 138 #if DEBUG_SYSCALLS_ERROR 109 printk("\n[ERROR] in %s : undefined pid argument %d / thread %x / process %x\n", 110 __FUNCTION__ , pid , this->trdid , process->pid ); 111 #endif 112 this->errno = EINVAL; 113 return -1; 114 } 115 116 // get cluster and local pointer on process 117 cxy_t process_cxy = GET_CXY( process_xp ); 118 process_t * process_ptr = (process_t *)GET_PTR( process_xp ); 139 printk("\n[ERROR] in %s : process %x in cluster %x not found / thread %x / process %x\n", 140 __FUNCTION__ , pid , cxy , this->trdid , process->pid ); 141 #endif 142 this->errno = EINVAL; 143 return -1; 144 } 145 146 // get local pointer on process 147 process_t * process = (process_t *)GET_PTR( process_xp ); 119 148 120 149 // call kernel function 121 if( process_cxy == local_cxy )122 { 123 vmm_display( process _ptr, true );150 if( cxy == local_cxy ) 151 { 152 vmm_display( process , true ); 124 153 } 125 154 else 126 155 { 127 rpc_vmm_display_client( process_cxy , process_ptr, true );156 rpc_vmm_display_client( cxy , process , true ); 128 157 } 129 158 } -
trunk/kernel/syscalls/sys_exit.c
r441 r443 51 51 #endif 52 52 53 // get owner process descriptor pointers and cluster54 xptr_t owner_xp = cluster_get_owner_process_from_pid( pid );53 // get owner process descriptor pointers 54 xptr_t owner_xp = process->owner_xp; 55 55 cxy_t owner_cxy = GET_CXY( owner_xp ); 56 56 process_t * owner_ptr = GET_PTR( owner_xp ); … … 62 62 hal_enable_irq( &save_sr ); 63 63 64 // mark for delete all process threads in all clusters 65 // (but the main thread and this calling thread)64 // mark for delete all process threads in all clusters, 65 // but the main thread and this calling thread 66 66 process_sigaction( pid , DELETE_ALL_THREADS ); 67 67 … … 81 81 #if( DEBUG_SYS_EXIT & 1) 82 82 if( tm_start > DEBUG_SYS_EXIT ) 83 printk("\n[DBG] %s : calling thread %x deleted itself/ process %x\n",83 printk("\n[DBG] %s : calling thread %x marked iself for delete / process %x\n", 84 84 __FUNCTION__ , this, pid ); 85 85 #endif -
trunk/kernel/syscalls/sys_fg.c
r438 r443 36 36 int sys_fg( pid_t pid ) 37 37 { 38 xptr_t process_xp; 38 xptr_t process_xp; // extended pointer on reference process descriptor 39 39 process_t * process_ptr; 40 40 cxy_t process_cxy; 41 xptr_t chdev_xp; 41 xptr_t file_xp; // extended pointer on STDIN file descriptor 42 xptr_t chdev_xp; // extended pointer on TXT0_RX chdev 42 43 chdev_t * chdev_ptr; 43 44 cxy_t chdev_cxy; … … 70 71 process_ptr = (process_t *)GET_PTR( process_xp ); 71 72 process_cxy = GET_CXY( process_xp ); 73 74 // get extended pointer on the reference process STDIN file descriptor 75 file_xp = hal_remote_lwd( XPTR( process_cxy , &process_ptr->fd_array.array[0] ) ); 72 76 73 77 // get extended pointer on TXT_RX chdev 74 chdev_xp = chdev_from_file( XPTR( process_cxy , &process_ptr->fd_array.array[0] ));78 chdev_xp = chdev_from_file( file_xp ); 75 79 76 80 // get chdev cluster and local pointer -
trunk/kernel/syscalls/sys_read.c
r441 r443 147 147 // check file readable 148 148 uint32_t attr = hal_remote_lw( XPTR( file_cxy , &file_ptr->attr ) ); 149 149 150 if( (attr & FD_ATTR_READ_ENABLE) == 0 ) 150 151 { … … 231 232 exit_sys_read = (uint32_t)tm_end; 232 233 233 printk("\n @@@@@@@@@@@@ timing to read character\n"234 printk("\n***** timing to read one character *****\n" 234 235 " - enter_sys_read = %d / delta %d\n" 235 236 " - enter_devfs_read = %d / delta %d\n" -
trunk/kernel/syscalls/sys_thread_cancel.c
r440 r443 37 37 cxy_t target_cxy; // target thread cluster identifier 38 38 ltid_t target_ltid; // target thread local index 39 xptr_t owner_xp; // extended pointer on owner process 39 40 cxy_t owner_cxy; // process owner cluster identifier 40 xptr_t owner_xp; // extended pointer on owner process41 41 42 42 // get killer thread pointers … … 44 44 process_t * process = this->process; 45 45 pid_t pid = process->pid; 46 47 #if DEBUG_SYS_THREAD_CANCEL 48 uint64_t tm_start; 49 uint64_t tm_end; 50 tm_start = hal_get_cycles(); 51 if( DEBUG_SYS_THREAD_CANCEL < tm_start ) 52 printk("\n[DBG] %s : thread %x enter to kill thread %x in process %x / cycle %d\n", 53 __FUNCTION__, this , trdid , pid , (uint32_t)tm_start ); 54 #endif 46 55 47 56 // get extended pointer on target thread … … 59 68 } 60 69 61 #if DEBUG_SYS_THREAD_CANCEL 62 uint64_t tm_start; 63 uint64_t tm_end; 64 tm_start = hal_get_cycles(); 65 if( DEBUG_SYS_THREAD_CANCEL < tm_start ) 66 printk("\n[DBG] %s : thread %x enter to kill thread %x / cycle %d\n", 67 __FUCTION__, this, GET_PTR( target_xp ), (uint32_t)tm_start ); 68 #endif 69 70 // get process owner cluster identifier 71 owner_cxy = CXY_FROM_PID( pid ); 70 // get process owner cluster 71 owner_xp = process->owner_xp; 72 owner_cxy = GET_CXY( owner_xp ); 72 73 73 74 // get target thread ltid and cluster … … 79 80 if( (target_cxy == owner_cxy) && (target_ltid == 0) ) 80 81 { 81 // get extended pointer on owner cluster82 owner_xp = cluster_get_owner_process_from_pid( pid );83 84 82 // mark for delete all threads but the main 85 83 hal_enable_irq( &save_sr ); … … 107 105 tm_end = hal_get_cycles(); 108 106 if( DEBUG_SYS_THREAD_CANCEL < tm_end ) 109 printk("\n[DBG] %s : thread %x exit after kill thread %x / cycle %d\n",110 __FU CTION__, this, GET_PTR( target_xp ), (uint32_t)tm_end );107 printk("\n[DBG] %s : thread %x exit after kill thread %x in process %x / cycle %d\n", 108 __FUNCTION__, this , trdid , pid , (uint32_t)tm_end ); 111 109 #endif 112 110 -
trunk/kernel/syscalls/sys_trace.c
r407 r443 1 1 /* 2 * sys_trace.c - show kernel active processes and threads2 * sys_trace.c - activate / desactivate the context switches trace for a given core 3 3 * 4 * Author Alain Greiner (c) (2016,2017 )4 * Author Alain Greiner (c) (2016,2017,2018) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 27 27 #include <thread.h> 28 28 #include <errno.h> 29 #include <shared_syscalls.h> 29 30 #include <syscalls.h> 30 31 31 /////////////////////////////// ///32 int sys_trace( uint32_t operation,33 pid_t pid,34 uint32_t trdid )32 /////////////////////////////// 33 int sys_trace( bool_t active, 34 cxy_t cxy, 35 lid_t lid ) 35 36 { 36 // get extended pointer on target thread 37 xptr_t thread_xp = thread_get_xptr( pid , trdid ); 37 uint32_t ncores; 38 38 39 if( thread_xp == XPTR_NULL ) 39 thread_t * this = CURRENT_THREAD; 40 process_t * process = this->process; 41 42 #if DEBUG_SYS_TRACE 43 uint64_t tm_start; 44 uint64_t tm_end; 45 tm_start = hal_get_cycles(); 46 if( DEBUG_SYS_TRACE < tm_start ) 47 printk("\n[DBG] %s : thread %d enter / process %x / cycle = %d\n", 48 __FUNCTION__, this, this->process->pid, (uint32_t)tm_start ); 49 #endif 50 51 // check cluster identifier 52 if( cluster_is_undefined( cxy ) ) 40 53 { 41 printk("\n[ERROR] in %s : undefined thread for PID = %x / TRDID = %x\n", 42 __FUNCTION__ , pid , trdid ); 43 CURRENT_THREAD->errno = EINVAL; 54 55 #if DEBUG_SYSCALLS_ERROR 56 printk("\n[ERROR] in %s : illegal cxy argument %x / thread %x / process %x\n", 57 __FUNCTION__ , cxy , this->trdid , process->pid ); 58 #endif 59 this->errno = EINVAL; 44 60 return -1; 45 61 } 46 62 47 if( operation == TRACE_OFF ) 63 // check core local index 64 ncores = hal_remote_lw( XPTR( cxy , &LOCAL_CLUSTER->cores_nr ) ); 65 if( lid >= ncores ) 48 66 { 49 // desactivate thread trace TODO50 67 51 printk("\n[DBG] %s : trace OFF for thread %x in process %x\n", 52 __FUNCTION__ , trdid , pid ); 53 } 54 else if( operation == TRACE_ON ) 55 { 56 // activate thread trace TODO 57 58 printk("\n[DBG] %s : trace ON for thread %x in process %x\n", 59 __FUNCTION__ , trdid , pid ); 60 } 61 else 62 { 63 printk("\n[ERROR] in %s : undefined operation\n", __FUNCTION__ ); 64 CURRENT_THREAD->errno = EINVAL; 68 #if DEBUG_SYSCALLS_ERROR 69 printk("\n[ERROR] in %s : illegal lid argument %x / thread %x / process %x\n", 70 __FUNCTION__ , lid , this->trdid , process->pid ); 71 #endif 72 this->errno = EINVAL; 65 73 return -1; 66 74 } 67 75 76 // get local pointer on target core 77 core_t * core = &LOCAL_CLUSTER->core_tbl[lid]; 78 79 // get extended pointer on target scheduler trace field 80 xptr_t trace_xp = XPTR( cxy , &core->scheduler.trace ); 81 82 if ( active ) hal_remote_sw( trace_xp , 1 ); 83 else hal_remote_sw( trace_xp , 0 ); 84 68 85 hal_fence(); 86 87 #if DEBUG_SYS_TRACE 88 tm_end = hal_get_cycles(); 89 if( DEBUG_SYS_TRACE < tm_end ) 90 printk("\n[DBG] %s : thread %x exit / process %x / cost = %d / cycle %d\n", 91 __FUNCTION__, this, this->process->pid, (uint32_t)(tm_end - tm_start) , (uint32_t)tm_end ); 92 #endif 69 93 70 94 return 0; -
trunk/kernel/syscalls/sys_wait.c
r440 r443 73 73 } 74 74 75 // get process owner cluster and calling thread trdid75 // get calling process owner cluster 76 76 cxy_t owner_cxy = CXY_FROM_PID( pid ); 77 trdid_t trdid = this->trdid;78 77 79 // wait must be executed by the main thread 78 // get calling thread trdid 79 trdid_t trdid = this->trdid; 80 81 // this function must be executed by the process main thread 80 82 if( (owner_cxy != local_cxy) || (LTID_FROM_TRDID(trdid) != 0) ) 81 83 { … … 113 115 child_state = (int)hal_remote_lw ( XPTR(child_cxy,&child_ptr->term_state)); 114 116 115 // test if child process is terminated,117 // test if this child process is terminated, 116 118 // but termination not yet reported to parent process 117 119 if( ((child_state & PROCESS_TERM_EXIT) || … … 120 122 ((child_state & PROCESS_TERM_WAIT) == 0) ) 121 123 { 122 // get pointer on main thread and PID from child owner process124 // get pointer on child main thread and PID from child owner process 123 125 child_pid = (pid_t) hal_remote_lw (XPTR( child_cxy , &child_ptr->pid )); 124 126 child_thread = (thread_t *)hal_remote_lpt(XPTR( child_cxy , 125 127 &child_ptr->th_tbl[0] )); 126 128 127 // set the PROCESS_FLAG_WAIT in owner child descriptor129 // set the PROCESS_FLAG_WAIT in owner child process descriptor 128 130 hal_remote_atomic_or( XPTR( child_cxy , &child_ptr->term_state ), 129 131 PROCESS_TERM_WAIT ); -
trunk/kernel/syscalls/sys_write.c
r441 r443 103 103 } 104 104 105 // enable IRQs106 hal_enable_irq( &save_sr );107 108 105 // get extended pointer on remote file descriptor 109 106 file_xp = process_fd_get_xptr( process , file_id ); … … 128 125 vfs_inode_type_t type = hal_remote_lw( XPTR( file_cxy , &file_ptr->type ) ); 129 126 130 // action depend on file type 127 // enable IRQs 128 hal_enable_irq( &save_sr ); 129 130 // action depend on file type 131 131 if( type == INODE_TYPE_FILE ) // check file writable & write to mapper 132 132 { … … 152 152 else if( type == INODE_TYPE_DEV ) // check ownership & write to device 153 153 { 154 // check user buffer size for TXT_TX 155 if( (type == INODE_TYPE_DEV) && (count >= CONFIG_TXT_KBUF_SIZE) ) 156 { 157 158 #if DEBUG_SYSCALLS_ERROR 159 printk("\n[ERROR] in %s : user buffer size %x too large / thread %x / process %x\n", 160 __FUNCTION__ , count, this->trdid, process->pid ); 161 #endif 162 this->errno = EINVAL; 163 return -1; 164 } 165 154 166 // move count bytes to device 155 167 nbytes = devfs_user_move( false, // from buffer to device … … 158 170 count ); 159 171 } 160 else 172 else // not FILE and not DEV 161 173 { 162 174 nbytes = 0; … … 192 204 exit_sys_write = (uint32_t)tm_end; 193 205 194 printk("\n @@@@@@@@@@@@ timing to write\n"206 printk("\n***** timing to write a string *****\n" 195 207 " - enter_sys_write = %d / delta %d\n" 196 208 " - enter_devfs_write = %d / delta %d\n" -
trunk/kernel/syscalls/syscalls.h
r440 r443 170 170 * [10] This function implement the exit system call terminating a POSIX process. 171 171 * It can be called by any thread running in any cluster. 172 * It uses both remote accesses to access the owner process descriptor, an sthe173 * RPC_PROCESS_SIGACTION to delete remote process and thread descriptors 172 * It uses both remote accesses to access the owner process descriptor, and the 173 * RPC_PROCESS_SIGACTION to delete remote process and thread descriptors. 174 174 * In the present implementation, this function implements actually the _exit(): 175 175 * - it does not flush open output streams. … … 600 600 601 601 /****************************************************************************************** 602 * [47] This non-standard function is used to activate / desactivate the trace for a thread603 * identified by the <trdid> and <pid> arguments.602 * [47] This debug function is used to activate / desactivate the context switches trace 603 * for a core identified by the <cxy> and <lid> arguments. 604 604 * It can be called by any other thread in the same process. 605 605 ****************************************************************************************** 606 * @ operation : operation type as defined below.607 * @ pid : processidentifier.608 * @ trdid : thread identifier.606 * @ active : activate trace if true / desactivate trace if false. 607 * @ cxy : cluster identifier. 608 * @ lid : core local index. 609 609 * @ returns O if success / returns -1 if failure. 610 610 *****************************************************************************************/ 611 int sys_trace( uint32_t operation,612 pid_t pid,613 uint32_t trdid );611 int sys_trace( bool_t active, 612 cxy_t cxy, 613 lid_t lid ); 614 614 615 615 /****************************************************************************************** -
trunk/libs/mini-libc/stdio.c
r439 r443 328 328 } 329 329 330 /////////////////////////////////// 331 int display_vmm( unsigned int pid ) 330 ////////////////////////////////// 331 int display_vmm( unsigned int cxy, 332 unsigned int pid ) 332 333 { 333 334 return hal_user_syscall( SYS_DISPLAY, 334 335 DISPLAY_VMM, 335 (reg_t)pid, 0, 0 ); 336 } 337 338 //////////////////////////////// 336 (reg_t)cxy, 337 (reg_t)pid, 0 ); 338 } 339 340 //////////////////////////////////// 339 341 int display_sched( unsigned int cxy, 340 342 unsigned int lid ) … … 383 385 } 384 386 385 /////////////////////////////// ///386 int trace( unsigned int operation,387 unsigned int pid,388 unsigned int trdid )387 /////////////////////////////// 388 int trace( unsigned int active, 389 unsigned int cxy, 390 unsigned int lid ) 389 391 { 390 392 return hal_user_syscall( SYS_TRACE, 391 (reg_t)pid, 392 (reg_t)trdid, 0, 0 ); 393 } 394 395 393 (reg_t)active, 394 (reg_t)cxy, 395 (reg_t)lid, 0 ); 396 } 397 398 -
trunk/libs/mini-libc/stdio.h
r439 r443 402 402 /*************************************************************************************** 403 403 * This debug function displays on the kernel terminal TXT0 404 * the state of the process VMM identified by the <pid> argument.404 * the state of the VMM forthe process <pid>, in cluster <cxy>. 405 405 * It can be called by any thread running in any cluster. 406 406 *************************************************************************************** … … 408 408 * @ return 0 if success / return -1 if illegal argument. 409 409 **************************************************************************************/ 410 int display_vmm( unsigned int pid ); 410 int display_vmm( unsigned int cxy, 411 unsigned int pid ); 411 412 412 413 /*************************************************************************************** … … 460 461 461 462 /***************************************************************************************** 462 * This debug function is used to activate / desactivate the trace for a thread463 * identified by the <trdid> and <pid> arguments.464 * It can be called by any other thread in the same process.465 ***************************************************************************************** 466 * @ operation : operation type.467 * @ pid : processidentifier.468 * @ trdid : thread identifier.463 * This debug function is used to activate / desactivate the context switches trace 464 * for a core identified by the <cxy> and <lid> arguments. 465 * It can be called by any thread running in any cluster. 466 ***************************************************************************************** 467 * @ active : activate trace if non zero / desactivate if zero. 468 * @ cxy : cluster identifier. 469 * @ lid : core local index. 469 470 * @ returns O if success / returns -1 if illegal arguments. 470 471 ****************************************************************************************/ 471 int trace( unsigned int operation,472 unsigned int pid,473 unsigned int trdid );472 int trace( unsigned int active, 473 unsigned int cxy, 474 unsigned int lid ); 474 475 475 476 -
trunk/libs/mini-libc/stdlib.c
r441 r443 553 553 printf("\n[ERROR] in %s : not implemented yet : do nothing\n", __FUNCTION__ ); 554 554 } 555 556 /////////// 557 void idbg() 558 { 559 char cmd; 560 unsigned int cxy; 561 unsigned int lid; 562 unsigned int txt; 563 unsigned int active; 564 565 while( 1 ) 566 { 567 printf("\n[idbg] cmd = "); 568 cmd = (char)getchar(); 569 570 if( cmd == 'h' ) 571 { 572 printf("h\n" 573 "p : display on TXT0 process descriptors in cluster[cxy]\n" 574 "s : display on TXT0 scheduler state for core[cxy,lid]\n" 575 "v : display on TXT0 VMM for calling process in cluster [cxy]\n" 576 "t : display on TXT0 process decriptors attached to TXT[tid]\n" 577 "y : activate/desactivate trace for core[cxy,lid]\n" 578 "x : force calling process to exit\n" 579 "c : resume calling process execution\n" 580 "h : list supported commands\n"); 581 } 582 else if( cmd == 'p' ) 583 { 584 printf("p / cxy = "); 585 cxy = getint(); 586 display_cluster_processes( cxy ); 587 } 588 else if( cmd == 's' ) 589 { 590 printf("s / cxy = "); 591 cxy = getint(); 592 printf(" / lid = "); 593 lid = getint(); 594 display_sched( cxy , lid ); 595 } 596 else if( cmd == 'v' ) 597 { 598 printf("v / cxy = "); 599 cxy = getint(); 600 display_vmm( cxy , (unsigned int)getpid() ); 601 } 602 else if( cmd == 't' ) 603 { 604 printf("t / txt_id = "); 605 txt = getint(); 606 display_txt_processes( txt ); 607 } 608 else if( cmd == 'y' ) 609 { 610 printf("y / active = "); 611 active = getint(); 612 printf(" / cxy = "); 613 cxy = getint(); 614 printf(" / lid = "); 615 lid = getint(); 616 trace( active , cxy , lid ); 617 } 618 else if( cmd == 'x' ) 619 { 620 printf("x\n"); 621 exit( 0 ); 622 } 623 else if( cmd == 'c' ) 624 { 625 printf("c\n"); 626 break; 627 } 628 } 629 } // end idbg() 630 631 632 -
trunk/libs/mini-libc/stdlib.h
r439 r443 130 130 int rand(); 131 131 132 /********************************************************************************************* 133 * This blocking function implements an user-level interactive debugger that can be 134 * introduced in any user application to display various kernel distributed structures 135 * related to the calling process. The supported commands are: 136 * - p (cxy) : display all processes descriptors in a given cluster. 137 * - s (cxy,lid) : display all threads attached to a given core in a given cluster. 138 * - v (cxy) : display the calling process VMM in a given cluster. 139 * - t (tid) : display all owner process descriptors attached to a given TXT terminal. 140 * - x : force the calling process to exit. 141 * - c : continue calling process execution. 142 ********************************************************************************************* 143 * @ return an integer value between 0 and RAND_MAX. 144 ********************************************************************************************/ 145 void idbg(); 146 147 132 148 #endif // _STDLIB_H_ -
trunk/params-hard.mk
r440 r443 2 2 3 3 ARCH = /users/alain/soc/tsar-trunk-svn-2013/platforms/tsar_generic_iob 4 X_SIZE = 14 X_SIZE = 2 5 5 Y_SIZE = 2 6 NB_PROCS = 26 NB_PROCS = 1 7 7 NB_TTYS = 3 8 8 FBF_WIDTH = 128
Note: See TracChangeset
for help on using the changeset viewer.