mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:02:45 +00:00 
			
		
		
		
	 5bc7882b68
			
		
	
	
		5bc7882b68
		
	
	
	
	
		
			
			...and also make the Process tick counters clock_t instead of u32. It seems harmless to get interrupted in the middle of reading these counters and reporting slightly fewer ticks in some category.
		
			
				
	
	
		
			29 lines
		
	
	
	
		
			811 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
	
		
			811 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #include <Kernel/Process.h>
 | |
| #include <Kernel/Time/TimeManagement.h>
 | |
| 
 | |
| namespace Kernel {
 | |
| 
 | |
| ErrorOr<FlatPtr> Process::sys$times(Userspace<tms*> user_times)
 | |
| {
 | |
|     VERIFY_NO_PROCESS_BIG_LOCK(this);
 | |
|     TRY(require_promise(Pledge::stdio));
 | |
| 
 | |
|     // There's no lock here, as it seems harmless to report intermediate values
 | |
|     // as long as each individual counter is intact.
 | |
|     tms times = {};
 | |
|     times.tms_utime = m_ticks_in_user;
 | |
|     times.tms_stime = m_ticks_in_kernel;
 | |
|     times.tms_cutime = m_ticks_in_user_for_dead_children;
 | |
|     times.tms_cstime = m_ticks_in_kernel_for_dead_children;
 | |
| 
 | |
|     TRY(copy_to_user(user_times, ×));
 | |
|     return TimeManagement::the().uptime_ms() & 0x7fffffff;
 | |
| }
 | |
| 
 | |
| }
 |