Changeset 635 for trunk/kernel/kern
- Timestamp:
- Jun 26, 2019, 11:42:37 AM (5 years ago)
- Location:
- trunk/kernel/kern
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/chdev.c
r625 r635 90 90 91 91 // allocate memory for chdev 92 req.type = KMEM_DEVICE; 93 req.flags = AF_ZERO; 94 chdev = (chdev_t *)kmem_alloc( &req ); 92 req.type = KMEM_KCM; 93 req.order = bits_log2( sizeof(chdev_t) ); 94 req.flags = AF_ZERO | AF_KERNEL; 95 chdev = kmem_alloc( &req ); 95 96 96 97 if( chdev == NULL ) return NULL; -
trunk/kernel/kern/cluster.c
r627 r635 4 4 * Author Ghassan Almaless (2008,2009,2010,2011,2012) 5 5 * Mohamed Lamine Karaoui (2015) 6 * Alain Greiner (2016,2017,2018 )6 * Alain Greiner (2016,2017,2018,2019) 7 7 * 8 8 * Copyright (c) UPMC Sorbonne Universites … … 109 109 cluster_t * cluster = LOCAL_CLUSTER; 110 110 111 // initialize the lock protecting the embedded kcm allocator112 busylock_init( &cluster->kcm_lock , LOCK_CLUSTER_KCM );113 114 111 #if DEBUG_CLUSTER_INIT 115 112 uint32_t cycle = (uint32_t)hal_get_cycles(); … … 148 145 149 146 // initialises embedded KCM 150 kcm_init( &cluster->kcm , KMEM_KCM ); 147 uint32_t i; 148 for( i = 0 ; i < 6 ; i++ ) kcm_init( &cluster->kcm[i] , i+6 ); 151 149 152 150 #if( DEBUG_CLUSTER_INIT & 1 ) 153 151 cycle = (uint32_t)hal_get_cycles(); 154 152 if( DEBUG_CLUSTER_INIT < cycle ) 155 printk("\n[%s] KCM initialized in cluster %x at cycle %d\n",153 printk("\n[%s] KCM[6:11] initialized in cluster %x at cycle %d\n", 156 154 __FUNCTION__ , local_cxy , hal_get_cycles() ); 157 155 #endif -
trunk/kernel/kern/cluster.h
r611 r635 126 126 ppm_t ppm; /*! embedded kernel page manager */ 127 127 khm_t khm; /*! embedded kernel heap manager */ 128 kcm_t kcm; /*! embedded kernel KCMs manager */ 129 130 kcm_t * kcm_tbl[KMEM_TYPES_NR]; /*! pointers on allocated KCMs */ 131 busylock_t kcm_lock; /*! protect kcm_tbl[] updates */ 128 kcm_t kcm[6]; /*! embedded kernel cache managers [6:11] */ 132 129 133 130 // RPC -
trunk/kernel/kern/kernel_init.c
r633 r635 251 251 "\n\n\t\t Advanced Locality Management Operating System / Multi Kernel Hybrid\n" 252 252 "\n\n\t\t %s / %d cluster(s) / %d core(s) per cluster\n\n", 253 CONFIG_ ALMOS_VERSION , nclusters , ncores );253 CONFIG_VERSION , nclusters , ncores ); 254 254 } 255 255 … … 1428 1428 } 1429 1429 1430 #if ( DEBUG_KERNEL_INIT & 1 )1430 #if CONFIG_INSTRUMENTATION_FOOTPRINT 1431 1431 if( (core_lid == 0) & (local_cxy == 0) ) 1432 1432 printk("\n\n***** memory fooprint for main kernel objects\n\n" … … 1439 1439 " - rpc fifo : %d bytes\n" 1440 1440 " - page descriptor : %d bytes\n" 1441 " - mapper root : %d bytes\n" 1441 " - mapper descriptor : %d bytes\n" 1442 " - vseg descriptor : %d bytes\n" 1442 1443 " - ppm manager : %d bytes\n" 1443 1444 " - kcm manager : %d bytes\n" … … 1445 1446 " - vmm manager : %d bytes\n" 1446 1447 " - gpt root : %d bytes\n" 1448 " - vfs inode : %d bytes\n" 1449 " - vfs dentry : %d bytes\n" 1450 " - vfs file : %d bytes\n" 1451 " - vfs context : %d bytes\n" 1452 " - xhtab root : %d bytes\n" 1447 1453 " - list item : %d bytes\n" 1448 1454 " - xlist item : %d bytes\n" … … 1462 1468 sizeof( page_t ), 1463 1469 sizeof( mapper_t ), 1470 sizeof( vseg_t ), 1464 1471 sizeof( ppm_t ), 1465 1472 sizeof( kcm_t ), … … 1467 1474 sizeof( vmm_t ), 1468 1475 sizeof( gpt_t ), 1476 sizeof( vfs_inode_t ), 1477 sizeof( vfs_dentry_t ), 1478 sizeof( vfs_file_t ), 1479 sizeof( vfs_ctx_t ), 1480 sizeof( xhtab_t ), 1469 1481 sizeof( list_entry_t ), 1470 1482 sizeof( xlist_entry_t ), … … 1486 1498 ///////////////////////////////////////////////////////////////////////////////// 1487 1499 1488 #if ( DEBUG_KERNEL_INIT & 1 )1500 #if DEBUG_KERNEL_INIT 1489 1501 thread_t * this = CURRENT_THREAD; 1490 1502 printk("\n[%s] : thread[%x,%x] on core[%x,%d] jumps to thread_idle_func() / cycle %d\n", -
trunk/kernel/kern/process.c
r633 r635 72 72 process_t * process_alloc( void ) 73 73 { 74 kmem_req_t 75 76 req.type = KMEM_ PROCESS;77 req. size = sizeof(process_t);74 kmem_req_t req; 75 76 req.type = KMEM_KCM; 77 req.order = bits_log2( sizeof(process_t) ); 78 78 req.flags = AF_KERNEL; 79 79 80 return (process_t *)kmem_alloc( &req );80 return kmem_alloc( &req ); 81 81 } 82 82 … … 86 86 kmem_req_t req; 87 87 88 req.type = KMEM_ PROCESS;88 req.type = KMEM_KCM; 89 89 req.ptr = process; 90 90 kmem_free( &req ); … … 166 166 #endif 167 167 168 // initialize VSL lock s168 // initialize VSL lock 169 169 remote_rwlock_init( XPTR( local_cxy , &vmm->vsl_lock ) , LOCK_VMM_VSL ); 170 170 171 // register kernel vsegs in VMM as required by the architecture171 // register kernel vsegs in user process VMM as required by the architecture 172 172 error = hal_vmm_kernel_update( process ); 173 173 if( error ) … … 179 179 #if (DEBUG_PROCESS_REFERENCE_INIT & 1) 180 180 if( DEBUG_PROCESS_REFERENCE_INIT < cycle ) 181 printk("\n[%s] thread[%x,%x] registered kernel vsegs for process %x\n",181 printk("\n[%s] thread[%x,%x] registered kernel vsegs in VSL for process %x\n", 182 182 __FUNCTION__, parent_pid, this->trdid, pid ); 183 183 #endif … … 374 374 printk("\n[%s] thread[%x,%x] exit for process %x / cycle %d\n", 375 375 __FUNCTION__, parent_pid, this->trdid, pid, cycle ); 376 #endif 377 378 #if (DEBUG_PROCESS_REFERENCE_INIT & 1) 379 hal_vmm_display( parent_xp , false ); 380 hal_vmm_display( XPTR( local_cxy , process ) , false ); 376 381 #endif 377 382 … … 1088 1093 } 1089 1094 } 1095 1090 1096 //////////////////////////////////////////////////// 1091 1097 error_t process_fd_register( xptr_t process_xp, … … 1356 1362 1357 1363 #if DEBUG_PROCESS_MAKE_FORK 1358 uint32_t cycle = (uint32_t)hal_get_cycles();1364 uint32_t cycle; 1359 1365 thread_t * this = CURRENT_THREAD; 1360 1366 trdid_t trdid = this->trdid; 1361 1367 pid_t pid = this->process->pid; 1368 #endif 1369 1370 #if( DEBUG_PROCESS_MAKE_FORK & 1 ) 1371 cycle = (uint32_t)hal_get_cycles(); 1362 1372 if( DEBUG_PROCESS_MAKE_FORK < cycle ) 1363 1373 printk("\n[%s] thread[%x,%x] enter / cluster %x / cycle %d\n", … … 1367 1377 // allocate a process descriptor 1368 1378 process = process_alloc(); 1379 1369 1380 if( process == NULL ) 1370 1381 { … … 1427 1438 printk("\n[%s] thread[%x,%x] copied VMM from parent to child / cycle %d\n", 1428 1439 __FUNCTION__, pid, trdid, cycle ); 1440 hal_vmm_display( XPTR( local_cxy , process ) , true ); 1429 1441 #endif 1430 1442 … … 1438 1450 cycle = (uint32_t)hal_get_cycles(); 1439 1451 if( DEBUG_PROCESS_MAKE_FORK < cycle ) 1440 printk("\n[%s] thread[%x,%x] / child takes TXT ownership / cycle %d\n",1441 __FUNCTION__ , pid, trdid, cycle );1452 printk("\n[%s] thread[%x,%x] / child_process %x takes TXT ownership / cycle %d\n", 1453 __FUNCTION__ , pid, trdid, new_pid, cycle ); 1442 1454 #endif 1443 1455 … … 1471 1483 #endif 1472 1484 1473 // set COW flag in DATA, ANON, REMOTE vsegs forparent process VMM1485 // set COW flag in DATA, ANON, REMOTE vsegs in parent process VMM 1474 1486 // this includes all parent process copies in all clusters 1475 1487 if( parent_process_cxy == local_cxy ) // reference is local … … 1489 1501 cycle = (uint32_t)hal_get_cycles(); 1490 1502 if( DEBUG_PROCESS_MAKE_FORK < cycle ) 1491 printk("\n[%s] thread[%x,%x] set COW in parent and child / cycle %d\n",1503 printk("\n[%s] thread[%x,%x] set COW in DATA / ANON / REMOTE for parent and child / cycle %d\n", 1492 1504 __FUNCTION__, pid, trdid, cycle ); 1493 1505 #endif … … 1546 1558 #if DEBUG_PROCESS_MAKE_EXEC 1547 1559 uint32_t cycle = (uint32_t)hal_get_cycles(); 1548 if( local_cxy == 0x11)1560 if( DEBUG_PROCESS_MAKE_EXEC < cycle ) 1549 1561 printk("\n[%s] thread[%x,%x] enters for %s / cycle %d\n", 1550 1562 __FUNCTION__, pid, thread->trdid, path, cycle ); … … 1569 1581 #if (DEBUG_PROCESS_MAKE_EXEC & 1) 1570 1582 cycle = (uint32_t)hal_get_cycles(); 1571 if( local_cxy == 0x11)1583 if( DEBUG_PROCESS_MAKE_EXEC < cycle ) 1572 1584 printk("\n[%s] thread[%x,%x] opened file <%s> / cycle %d\n", 1573 1585 __FUNCTION__, pid, thread->trdid, path, cycle ); … … 1579 1591 #if (DEBUG_PROCESS_MAKE_EXEC & 1) 1580 1592 cycle = (uint32_t)hal_get_cycles(); 1581 if( local_cxy == 0x11)1593 if( DEBUG_PROCESS_MAKE_EXEC < cycle ) 1582 1594 printk("\n[%s] thread[%x,%x] deleted existing threads / cycle %d\n", 1583 1595 __FUNCTION__, pid, thread->trdid, cycle ); … … 1589 1601 #if( DEBUG_PROCESS_MAKE_EXEC & 1 ) 1590 1602 cycle = (uint32_t)hal_get_cycles(); 1591 if( local_cxy == 0x11)1603 if( DEBUG_PROCESS_MAKE_EXEC < cycle ) 1592 1604 printk("\n[%s] thread[%x,%x] completed VMM reset / cycle %d\n", 1593 1605 __FUNCTION__, pid, thread->trdid, cycle ); … … 1606 1618 #if( DEBUG_PROCESS_MAKE_EXEC & 1 ) 1607 1619 cycle = (uint32_t)hal_get_cycles(); 1608 if( local_cxy == 0x11)1620 if( DEBUG_PROCESS_MAKE_EXEC < cycle ) 1609 1621 printk("\n[%s] thread[%x,%x] registered args/envs vsegs / cycle %d\n", 1610 1622 __FUNCTION__, pid, thread->trdid, cycle ); … … 1624 1636 #if( DEBUG_PROCESS_MAKE_EXEC & 1 ) 1625 1637 cycle = (uint32_t)hal_get_cycles(); 1626 if( local_cxy == 0x11)1638 if( DEBUG_PROCESS_MAKE_EXEC < cycle ) 1627 1639 printk("\n[%s] thread[%x,%x] registered code/data vsegs / cycle %d\n", 1628 1640 __FUNCTION__, pid, thread->trdid, cycle ); … … 1674 1686 hal_core_sleep(); 1675 1687 } 1688 1689 #if (DEBUG_PROCESS_ZERO_CREATE & 1) 1690 if( DEBUG_PROCESS_ZERO_CREATE < cycle ) 1691 printk("\n[%s] allocated pid %x in cluster %x\n", __FUNCTION__, pid, local_cxy ); 1692 #endif 1676 1693 1677 1694 // initialize PID, REF_XP, PARENT_XP, and STATE … … 1684 1701 process->term_state = 0; 1685 1702 1686 // initi lise VSL as empty1703 // initialize VSL as empty 1687 1704 vmm->vsegs_nr = 0; 1688 1705 xlist_root_init( XPTR( local_cxy , &vmm->vsegs_root ) ); 1689 1706 1690 // initialise GPT as empty 1707 #if (DEBUG_PROCESS_ZERO_CREATE & 1) 1708 if( DEBUG_PROCESS_ZERO_CREATE < cycle ) 1709 printk("\n[%s] initialized VSL empty in cluster %x\n", __FUNCTION__, local_cxy ); 1710 #endif 1711 1712 // initialize GPT as empty 1691 1713 error = hal_gpt_create( &vmm->gpt ); 1714 1692 1715 if( error ) 1693 1716 { … … 1695 1718 hal_core_sleep(); 1696 1719 } 1720 1721 #if (DEBUG_PROCESS_ZERO_CREATE & 1) 1722 if( DEBUG_PROCESS_ZERO_CREATE < cycle ) 1723 printk("\n[%s] initialized GPT empty in cluster %x\n", __FUNCTION__, local_cxy ); 1724 #endif 1697 1725 1698 1726 // initialize VSL and GPT locks … … 1701 1729 // create kernel vsegs in GPT and VSL, as required by the hardware architecture 1702 1730 error = hal_vmm_kernel_init( info ); 1731 1703 1732 if( error ) 1704 1733 { … … 1706 1735 hal_core_sleep(); 1707 1736 } 1737 1738 #if (DEBUG_PROCESS_ZERO_CREATE & 1) 1739 if( DEBUG_PROCESS_ZERO_CREATE < cycle ) 1740 printk("\n[%s] initialized hal specific VMM in cluster%x\n", __FUNCTION__, local_cxy ); 1741 #endif 1708 1742 1709 1743 // reset th_tbl[] array and associated fields … … 1716 1750 rwlock_init( &process->th_lock , LOCK_PROCESS_THTBL ); 1717 1751 1752 #if (DEBUG_PROCESS_ZERO_CREATE & 1) 1753 if( DEBUG_PROCESS_ZERO_CREATE < cycle ) 1754 printk("\n[%s] initialized th_tbl[] in cluster%x\n", __FUNCTION__, local_cxy ); 1755 #endif 1718 1756 1719 1757 // reset children list as empty … … 1722 1760 remote_queuelock_init( XPTR( local_cxy , &process->children_lock ), 1723 1761 LOCK_PROCESS_CHILDREN ); 1762 1763 #if (DEBUG_PROCESS_ZERO_CREATE & 1) 1764 if( DEBUG_PROCESS_ZERO_CREATE < cycle ) 1765 printk("\n[%s] initialized children list in cluster%x\n", __FUNCTION__, local_cxy ); 1766 #endif 1724 1767 1725 1768 // register kernel process in cluster manager local_list … … 1759 1802 // allocates memory for process descriptor from local cluster 1760 1803 process = process_alloc(); 1804 1805 1761 1806 if( process == NULL ) 1762 1807 { … … 1840 1885 1841 1886 #if (DEBUG_PROCESS_INIT_CREATE & 1) 1842 hal_vmm_display( process, true );1887 hal_vmm_display( XPTR( local_cxy , process ) , true ); 1843 1888 #endif 1844 1889 -
trunk/kernel/kern/process.h
r625 r635 4 4 * Authors Ghassan Almaless (2008,2009,2010,2011,2012) 5 5 * Mohamed Lamine Karaoui (2015) 6 * Alain Greiner (2016,2017,2018 )6 * Alain Greiner (2016,2017,2018,2019) 7 7 * 8 8 * Copyright (c) UPMC Sorbonne Universites … … 231 231 * descriptor, defined by the <parent_xp> argument. The <process> and <pid> arguments 232 232 * are previously allocated by the caller. This function can be called by two functions: 233 * 1)process_init_create() : process is the INIT process, and parent is process-zero.234 * 2) process_make_fork(): the parent process descriptor is generally remote.233 * - process_init_create() : process is the INIT process, and parent is process-zero. 234 * - process_make_fork() : the parent process descriptor is generally remote. 235 235 * The following fields are initialised : 236 236 * - It set the pid / ppid / ref_xp / parent_xp / state fields. -
trunk/kernel/kern/rpc.c
r632 r635 75 75 &rpc_vmm_get_vseg_server, // 20 76 76 &rpc_vmm_global_update_pte_server, // 21 77 &rpc_ kcm_alloc_server,// 2278 &rpc_ kcm_free_server,// 2377 &rpc_undefined, // 22 78 &rpc_undefined, // 23 79 79 &rpc_mapper_sync_server, // 24 80 &rpc_ mapper_handle_miss_server,// 2580 &rpc_undefined, // 25 81 81 &rpc_vmm_delete_vseg_server, // 26 82 82 &rpc_vmm_create_vseg_server, // 27 83 83 &rpc_vmm_set_cow_server, // 28 84 &rpc_ hal_vmm_display_server,// 2984 &rpc_undefined, // 29 85 85 }; 86 86 … … 111 111 "GET_VSEG", // 20 112 112 "GLOBAL_UPDATE_PTE", // 21 113 " KCM_ALLOC",// 22114 " KCM_FREE",// 23113 "undefined_22", // 22 114 "undefined_23", // 23 115 115 "MAPPER_SYNC", // 24 116 " MAPPER_HANDLE_MISS",// 25116 "undefined_25", // 25 117 117 "VMM_DELETE_VSEG", // 26 118 118 "VMM_CREATE_VSEG", // 27 119 119 "VMM_SET_COW", // 28 120 " VMM_DISPLAY",// 29120 "undefined_29", // 29 121 121 }; 122 122 … … 557 557 // release memory to local pmem 558 558 kmem_req_t req; 559 req.type = KMEM_P AGE;559 req.type = KMEM_PPM; 560 560 req.ptr = page; 561 561 kmem_free( &req ); … … 2231 2231 ///////////////////////////////////////////////////////////////////////////////////////// 2232 2232 2233 /* 2233 2234 ////////////////////////////////////////// 2234 2235 void rpc_kcm_alloc_client( cxy_t cxy, … … 2304 2305 #endif 2305 2306 } 2307 */ 2306 2308 2307 2309 ///////////////////////////////////////////////////////////////////////////////////////// … … 2309 2311 ///////////////////////////////////////////////////////////////////////////////////////// 2310 2312 2313 /* 2311 2314 ///////////////////////////////////////// 2312 2315 void rpc_kcm_free_client( cxy_t cxy, … … 2377 2380 #endif 2378 2381 } 2379 2380 ///////////////////////////////////////////////////////////////////////////////////////// 2381 // [25] Marshaling functions attached to RPC_MAPPER_SYNC 2382 */ 2383 2384 ///////////////////////////////////////////////////////////////////////////////////////// 2385 // [24] Marshaling functions attached to RPC_MAPPER_SYNC 2382 2386 ///////////////////////////////////////////////////////////////////////////////////////// 2383 2387 … … 2459 2463 ///////////////////////////////////////////////////////////////////////////////////////// 2460 2464 2465 /* 2461 2466 ////////////////////////////////////////////////////////// 2462 2467 void rpc_mapper_handle_miss_client( cxy_t cxy, … … 2541 2546 #endif 2542 2547 } 2548 */ 2543 2549 2544 2550 ///////////////////////////////////////////////////////////////////////////////////////// … … 2784 2790 2785 2791 ///////////////////////////////////////////////////////////////////////////////////////// 2786 // [29] Marshaling functions attached to RPC_VMM_DISPLAY 2787 ///////////////////////////////////////////////////////////////////////////////////////// 2788 2792 // [29] RPC_VMM_DISPLAY deprecated [AG] June 2019 2793 ///////////////////////////////////////////////////////////////////////////////////////// 2794 2795 /* 2789 2796 ///////////////////////////////////////////// 2790 2797 void rpc_hal_vmm_display_client( cxy_t cxy, … … 2856 2863 } 2857 2864 2858 2865 */ -
trunk/kernel/kern/rpc.h
r632 r635 60 60 typedef enum 61 61 { 62 RPC_UNDEFINED_0 = 0, // RPC_PMEM_GET_PAGES deprecated [AG]63 RPC_UNDEFINED_1 = 1, // RPC_PMEM_RELEASE_PAGES deprecated [AG]64 RPC_UNDEFINED_2 = 2, // RPC_PMEM_DISPLAY deprecated [AG]62 RPC_UNDEFINED_0 = 0, // RPC_PMEM_GET_PAGES deprecated [AG] 63 RPC_UNDEFINED_1 = 1, // RPC_PMEM_RELEASE_PAGES deprecated [AG] 64 RPC_UNDEFINED_2 = 2, // RPC_PMEM_DISPLAY deprecated [AG] 65 65 RPC_PROCESS_MAKE_FORK = 3, 66 66 RPC_USER_DIR_CREATE = 4, … … 84 84 RPC_VMM_GET_VSEG = 20, 85 85 RPC_VMM_GLOBAL_UPDATE_PTE = 21, 86 RPC_ KCM_ALLOC = 22,87 RPC_ KCM_FREE = 23,86 RPC_UNDEFINED_22 = 22, // RPC_KCM_ALLOC deprecated [AG] 87 RPC_UNDEFINED_23 = 23, // RPC_KCM_FREE deprecated [AG] 88 88 RPC_MAPPER_SYNC = 24, 89 RPC_ MAPPER_HANDLE_MISS = 25,89 RPC_UNDEFUNED_25 = 25, // RPC_MAPPER_HANDLE_MISS deprecated [AG] 90 90 RPC_VMM_DELETE_VSEG = 26, 91 91 RPC_VMM_CREATE_VSEG = 27, 92 92 RPC_VMM_SET_COW = 28, 93 RPC_ VMM_DISPLAY = 29,93 RPC_UNDEFINED_29 = 29, // RPC_VMM_DISPLAY deprecated [AG] 94 94 95 95 RPC_MAX_INDEX = 30, … … 574 574 * @ buf_xp : [out] buffer for extended pointer on allocated buffer. 575 575 **********************************************************************************/ 576 577 /* 576 578 void rpc_kcm_alloc_client( cxy_t cxy, 577 579 uint32_t kmem_type, … … 579 581 580 582 void rpc_kcm_alloc_server( xptr_t xp ); 583 */ 581 584 582 585 /*********************************************************************************** … … 588 591 * @ kmem_type : [in] KCM object type (as defined in kmem.h). 589 592 **********************************************************************************/ 593 594 /* 590 595 void rpc_kcm_free_client( cxy_t cxy, 591 596 void * buf, … … 593 598 594 599 void rpc_kcm_free_server( xptr_t xp ); 600 */ 595 601 596 602 /*********************************************************************************** … … 621 627 * @ error : [out] error status (0 if success). 622 628 **********************************************************************************/ 629 /* 623 630 void rpc_mapper_handle_miss_client( cxy_t cxy, 624 631 struct mapper_s * mapper, … … 628 635 629 636 void rpc_mapper_handle_miss_server( xptr_t xp ); 630 637 */ 631 638 /*********************************************************************************** 632 639 * [26] The RPC_VMM_DELETE_VSEG allows any client thread to request a remote … … 699 706 * @ detailed : [in] detailed display if true. 700 707 **********************************************************************************/ 708 709 /* 701 710 void rpc_hal_vmm_display_client( cxy_t cxy, 702 711 struct process_s * process, … … 704 713 705 714 void rpc_hal_vmm_display_server( xptr_t xp ); 706 715 */ 707 716 708 717 #endif -
trunk/kernel/kern/scheduler.c
r630 r635 180 180 sched = &core->scheduler; 181 181 182 ////////////////// scan user threads to handle bothACK and DELETE requests182 ////////////////// scan user threads to handle ACK and DELETE requests 183 183 root = &sched->u_root; 184 184 iter = root->next; … … 195 195 { 196 196 197 // check t hread blocked197 // check target thread blocked 198 198 assert( (thread->blocked & THREAD_BLOCKED_GLOBAL) , "thread not blocked" ); 199 199 … … 206 206 207 207 // handle REQ_DELETE only if target thread != calling thread 208 if( (thread->flags & THREAD_FLAG_REQ_DELETE) && (thread != CURRENT_THREAD) ) 209 { 208 if( thread->flags & THREAD_FLAG_REQ_DELETE ) 209 { 210 211 // check calling thread != target thread 212 assert( (thread != CURRENT_THREAD) , "calling thread cannot delete itself" ); 213 210 214 // get thread process descriptor 211 215 process = thread->process; … … 497 501 remote_fifo_t * fifo = &LOCAL_CLUSTER->rpc_fifo[lid]; 498 502 503 #if DEBUG_SCHED_YIELD 504 uint32_t cycle = (uint32_t)hal_get_cycles(); 505 #endif 506 499 507 #if (DEBUG_SCHED_YIELD & 0x1) 500 if( sched->trace )508 if( sched->trace || (cycle > DEBUG_SCHED_YIELD) ) 501 509 sched_display( lid ); 502 510 #endif … … 551 559 552 560 #if DEBUG_SCHED_YIELD 553 if( sched->trace )561 if( sched->trace || (cycle > DEBUG_SCHED_YIELD) ) 554 562 printk("\n[%s] core[%x,%d] / cause = %s\n" 555 563 " thread %x (%s) (%x,%x) => thread %x (%s) (%x,%x) / cycle %d\n", 556 564 __FUNCTION__, local_cxy, lid, cause, 557 565 current, thread_type_str(current->type), current->process->pid, current->trdid,next , 558 thread_type_str(next->type) , next->process->pid , next->trdid , (uint32_t)hal_get_cycles());566 thread_type_str(next->type) , next->process->pid , next->trdid , cycle ); 559 567 #endif 560 568 … … 567 575 busylock_release( &sched->lock ); 568 576 569 #if (DEBUG_SCHED_YIELD & 1)570 if( sched->trace )577 #if DEBUG_SCHED_YIELD 578 if( sched->trace || (cycle > DEBUG_SCHED_YIELD) ) 571 579 printk("\n[%s] core[%x,%d] / cause = %s\n" 572 580 " thread %x (%s) (%x,%x) continue / cycle %d\n", -
trunk/kernel/kern/thread.c
r633 r635 78 78 static thread_t * thread_alloc( void ) 79 79 { 80 page_t * page; // pointer on page descriptor containing thread descriptor81 80 kmem_req_t req; // kmem request 82 81 83 82 // allocates memory for thread descriptor + kernel stack 84 req.type = KMEM_P AGE;85 req. size= CONFIG_THREAD_DESC_ORDER;83 req.type = KMEM_PPM; 84 req.order = CONFIG_THREAD_DESC_ORDER; 86 85 req.flags = AF_KERNEL | AF_ZERO; 87 page = kmem_alloc( &req ); 88 89 if( page == NULL ) return NULL; 90 91 // return pointer on new thread descriptor 92 xptr_t base_xp = ppm_page2base( XPTR(local_cxy , page ) ); 93 return GET_PTR( base_xp ); 86 87 return kmem_alloc( &req ); 94 88 95 89 } // end thread_alloc() … … 125 119 { 126 120 127 // check type and trdid fields initialized121 // check type and trdid fields are initialized 128 122 assert( (thread->type == type) , "bad type argument" ); 129 123 assert( (thread->trdid == trdid) , "bad trdid argument" ); … … 133 127 thread_t * this = CURRENT_THREAD; 134 128 if( DEBUG_THREAD_INIT < cycle ) 135 printk("\n[%s] thread[%x,%x] enter for thread %x in process %x/ cycle %d\n",136 __FUNCTION__, this->process->pid, this->trdid, thread->trdid, process->pid, cycle );129 printk("\n[%s] thread[%x,%x] enter for thread[%x,%x] / cycle %d\n", 130 __FUNCTION__, this->process->pid, this->trdid, process->pid, thread->trdid, cycle ); 137 131 #endif 138 132 … … 192 186 cycle = (uint32_t)hal_get_cycles(); 193 187 if( DEBUG_THREAD_INIT < cycle ) 194 printk("\n[%s] thread[%x,%x] exit for thread %x in process %x/ cycle %d\n",195 __FUNCTION__, this->process->pid, this->trdid, thread, process->pid, cycle );188 printk("\n[%s] thread[%x,%x] exit for thread[%x,%x] / cycle %d\n", 189 __FUNCTION__, this->process->pid, this->trdid, process->pid, thread->trdid, cycle ); 196 190 #endif 197 191 … … 580 574 vpn_t parent_vpn_size = hal_remote_l32( XPTR( parent_cxy, &parent_us_vseg->vpn_size ) ); 581 575 vpn_t child_vpn_base = child_us_vseg->vpn_base; 576 582 577 for( parent_vpn = parent_vpn_base , child_vpn = child_vpn_base ; 583 578 parent_vpn < (parent_vpn_base + parent_vpn_size) ; … … 625 620 #if (DEBUG_THREAD_USER_FORK & 1) 626 621 if( DEBUG_THREAD_USER_FORK < cycle ) 627 printk("\n[%s] thread[%x,%x] copied all stack vseg PTEs tochild GPT\n",622 printk("\n[%s] thread[%x,%x] copied STACK vseg PTEs & set COW in child GPT\n", 628 623 __FUNCTION__, this->process->pid, this->trdid ); 629 624 #endif … … 636 631 #if (DEBUG_THREAD_USER_FORK & 1) 637 632 if( DEBUG_THREAD_USER_FORK < cycle ) 638 printk("\n[%s] thread[%x,%x] set the COW flag for stackvseg in parent GPT\n",633 printk("\n[%s] thread[%x,%x] set COW for STACK vseg in parent GPT\n", 639 634 __FUNCTION__, this->process->pid, this->trdid ); 640 635 #endif … … 906 901 thread_assert_can_yield( thread , __FUNCTION__ ); 907 902 908 // update target process instrumentation counter 909 // process->vmm.pgfault_nr += thread->info.pgfault_nr; 903 #if CONFIG_INSTRUMENTATION_PGFAULTS 904 process->vmm.false_pgfault_nr += thread->info.false_pgfault_nr; 905 process->vmm.local_pgfault_nr += thread->info.local_pgfault_nr; 906 process->vmm.global_pgfault_nr += thread->info.global_pgfault_nr; 907 process->vmm.false_pgfault_cost += thread->info.false_pgfault_cost; 908 process->vmm.local_pgfault_cost += thread->info.local_pgfault_cost; 909 process->vmm.global_pgfault_cost += thread->info.global_pgfault_cost; 910 #endif 910 911 911 912 // remove thread from process th_tbl[] 912 913 count = process_remove_thread( thread ); 913 914 914 // release memory allocated for CPU context and FPU context if required915 // release memory allocated for CPU context and FPU context 915 916 hal_cpu_context_destroy( thread ); 916 917 hal_fpu_context_destroy( thread ); … … 933 934 // release memory for thread descriptor (including kernel stack) 934 935 kmem_req_t req; 935 xptr_t base_xp = ppm_base2page( XPTR(local_cxy , thread ) ); 936 937 req.type = KMEM_PAGE; 938 req.ptr = GET_PTR( base_xp ); 936 req.type = KMEM_PPM; 937 req.ptr = thread; 939 938 kmem_free( &req ); 940 939 -
trunk/kernel/kern/thread.h
r629 r635 101 101 { 102 102 uint32_t false_pgfault_nr; /*! number of local page fault */ 103 uint32_t local_pgfault_nr; /*! number of local page fault */ 104 uint32_t global_pgfault_nr; /*! number of global page fault */ 103 105 uint32_t false_pgfault_cost; /*! cumulated cost */ 104 uint32_t local_pgfault_nr; /*! number of local page fault */105 106 uint32_t local_pgfault_cost; /*! cumulated cost */ 106 uint32_t global_pgfault_nr; /*! number of global page fault */107 107 uint32_t global_pgfault_cost; /*! cumulated cost */ 108 108 … … 339 339 * this. This includes the thread descriptor itself, the associated CPU and FPU context, 340 340 * and the physical memory allocated for an user thread stack. 341 * This function does not remove the thread from the scheduler, as this is done by 342 * the scheduler itself. 341 343 *************************************************************************************** 342 344 * @ thread : pointer on the thread descriptor to release. … … 394 396 * The calling thread can run in any cluster, as it uses remote accesses. 395 397 * This function makes a kernel panic if the target thread is the main thread, 396 * because *the main thread deletion will cause the process deletion, and a process398 * because the main thread deletion will cause the process deletion, and a process 397 399 * must be deleted by the parent process, running the wait function. 398 400 * If the target thread is running in "attached" mode, and the <is_forced> argument
Note: See TracChangeset
for help on using the changeset viewer.