Changeset 367 for trunk/kernel/kern
- Timestamp:
- Aug 14, 2017, 11:39:03 AM (7 years ago)
- Location:
- trunk/kernel/kern
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/core.c
r337 r367 47 47 core->time_stamp = 0; 48 48 core->ticks_nr = 0; 49 core->ticks_period = CONFIG_SCHED_TICK_PERIOD;50 49 core->usage = 0; 51 50 core->spurious_irqs = 0; … … 72 71 uint32_t * tm_us ) 73 72 { 74 uint64_t cycles = hal_get_cycles(); 75 76 *tm_s = (cycles / CONFIG_CYCLES_PER_MS); 77 *tm_us = (cycles % CONFIG_CYCLES_PER_MS) / (CONFIG_CYCLES_PER_MS / 1000000); 73 *tm_s = (core->ticks_nr*CONFIG_SCHED_TICK_PERIOD)/1000; 74 *tm_us = (core->ticks_nr*CONFIG_SCHED_TICK_PERIOD*1000)%1000000; 78 75 } 79 76 77 /* deprecated 14/08/2017 [AG] 80 78 ////////////////////////////////////// 81 79 void core_time_update( core_t * core ) … … 99 97 hal_fence(); 100 98 } 99 */ 101 100 102 101 //////////////////////////////// … … 105 104 uint32_t ticks; 106 105 107 // update cycles and ticks counter 108 core_time_update( core ); 109 110 // get current ticks number 111 ticks = core->ticks_nr; 106 // update ticks counter 107 ticks = core->ticks_nr++; 112 108 113 109 // handle pending alarms TODO ??? [AG] 114 110 // alarm_clock( &core->alarm_mgr , ticks ); 115 111 116 // handle scheduler TODO improve the scheduling condition ... AG 117 if( (ticks % 10) == 0 ) sched_yield( NULL ); 118 119 /* 120 // compute elapsed time, taking into account 32 bits register wrap 121 uint32_t elapsed; 122 uint32_t time_now = hal_get_cycles(); 123 uint32_t time_last = this->time_last_check; 124 if( time_now < time_last ) elapsed = (0xFFFFFFFF - time_last) + time_now; 125 else elapsed = time_now - time_last; 126 127 // update thread time 128 this->time_last_check = time_now; 129 130 // check elapsed time 131 if( elapsed < CONFIG_CORE_CHECK_EVERY ) return false; 132 else return true; 133 */ 112 // handle scheduler 113 if( (ticks % CONFIG_SCHED_TICKS_PER_QUANTUM) == 0 ) sched_yield( NULL ); 134 114 135 115 // update DQDT TODO This update should depend on the cluster identifier, 136 116 // to avoid simultaneous updates from various clusters ... AG 137 if( ((ticks % CONFIG_DQDT_PERIOD) == 0) && (core->lid == 0) ) dqdt_global_update(); 117 if( ((ticks % CONFIG_DQDT_TICKS_PER_QUANTUM) == 0) && (core->lid == 0) ) 118 dqdt_global_update(); 138 119 } 139 120 … … 171 152 void core_reset_stats( core_t * core ) 172 153 { 173 core_time_update(core);174 175 154 core->ticks_nr = 0; 176 155 core->usage = 0; -
trunk/kernel/kern/core.h
r279 r367 50 50 lid_t lid; /*! core local index in cluster */ 51 51 gid_t gid; /*! core global identifier (hardware index) */ 52 52 53 uint64_t cycles; /*! total number of cycles (from hard reset) */ 53 54 uint32_t time_stamp; /*! previous time stamp (read from register) */ 55 54 56 uint32_t ticks_nr; /*! number of elapsed ticks */ 55 uint32_t ticks_period; /*! number of cycles between two ticks */56 57 uint32_t usage; /*! cumulated busy_percent (idle / total) */ 57 58 uint32_t spurious_irqs; /*! for instrumentation... */ -
trunk/kernel/kern/printk.h
r337 r367 250 250 251 251 #if CONFIG_RPC_DEBUG 252 #define rpc_dmsg(...) printk(__VA_ARGS__)252 #define rpc_dmsg(...) if(hal_time_stamp() > CONFIG_RPC_DEBUG) printk(__VA_ARGS__) 253 253 #else 254 254 #define rpc_dmsg(...) -
trunk/kernel/kern/process.c
r337 r367 632 632 parent_pid = hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid ) ); 633 633 634 exec_dmsg("\n[INFO] %s : enters in cluster %xfor path = %s\n",635 __FUNCTION__ , local_cxy, path );634 exec_dmsg("\n[INFO] %s : thread %x on core[%x,‰d] enters for path = %s\n", 635 __FUNCTION__, CURRENT_THREAD->trdid, local_cxy, CURRENT_THREAD->core->lid, path ); 636 636 637 637 // create new process descriptor … … 659 659 process_reference_init( process , pid , parent_xp ); 660 660 661 exec_dmsg("\n[INFO] %s : created process %x in cluster%x / path = %s\n",662 __FUNCTION__, pid , local_cxy, path );661 exec_dmsg("\n[INFO] %s : thread %x on core[%x,‰d] created process %x / path = %s\n", 662 __FUNCTION__, CURRENT_THREAD->trdid, local_cxy, CURRENT_THREAD->core->lid, pid, path ); 663 663 664 664 // initialize vfs_root and vfs_cwd from parent process … … 676 676 677 677 exec_dmsg("\n[INFO] %s : fd_array copied from process %x to process %x\n", 678 678 __FUNCTION__, parent_pid , pid ); 679 679 680 680 // initialize signal manager TODO ??? [AG] … … 693 693 } 694 694 695 exec_dmsg("\n[INFO] %s : code and data vsegs from <%s> registered for process %x\n",696 __FUNCTION__ , path , pid);695 exec_dmsg("\n[INFO] %s : code and data vsegs registered for process %x / path = %s\n", 696 __FUNCTION__ , pid , path ); 697 697 698 698 // select a core in cluster -
trunk/kernel/kern/thread.c
r338 r367 638 638 { 639 639 thread_t * this = CURRENT_THREAD; 640 return ( (this->local_locks == 0) && (this->remote_locks == 0));641 } 642 643 ///////////////////////// //644 bool_tthread_check_sched()640 return (this->local_locks == 0) && (this->remote_locks == 0); 641 } 642 643 ///////////////////////// 644 void thread_check_sched() 645 645 { 646 646 thread_t * this = CURRENT_THREAD; 647 647 648 // check locks count 649 if( (this->local_locks != 0) || (this->remote_locks != 0) )650 return false;651 652 if( this->flags & THREAD_FLAG_SCHED )648 if( (this->local_locks == 0) && 649 (this->remote_locks == 0) && 650 (this->flags & THREAD_FLAG_SCHED) ) 651 { 652 this->flags &= ~THREAD_FLAG_SCHED; 653 653 sched_yield( NULL ); 654 655 return true; 656 657 #if 0 658 // compute elapsed time, taking into account 32 bits register wrap 659 uint32_t elapsed; 660 uint32_t time_now = hal_get_cycles(); 661 uint32_t time_last = this->time_last_check; 662 if( time_now < time_last ) elapsed = (0xFFFFFFFF - time_last) + time_now; 663 else elapsed = time_now - time_last; 664 665 // update thread time 666 this->time_last_check = time_now; 667 668 // check elapsed time 669 if( elapsed < CONFIG_CORE_CHECK_EVERY ) return false; 670 else return true; 671 #endif 654 } 672 655 } 673 656 -
trunk/kernel/kern/thread.h
r337 r367 368 368 *************************************************************************************** 369 369 * @ thread : local pointer on target thread. 370 * @ mask : mask on selected signal.370 *s released all locks @ mask : mask on selected signal. 371 371 **************************************************************************************/ 372 372 inline void thread_set_signal( thread_t * thread, … … 400 400 401 401 /*************************************************************************************** 402 * This function checks if the calling thread must be descheduled.403 * **************************************************************************************404 * @ returns true if no locks taken, and elapsed time.405 **************************************************************************************/ 406 bool_tthread_check_sched();402 * This function implements the delayed descheduling machanism : It is called by 403 * all lock release functions, and calls the sched_yield() function when all locks 404 * have beeen released and the THREAD_FLAG_SCHED flag is set. 405 **************************************************************************************/ 406 void thread_check_sched(); 407 407 408 408 /***************************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.