示例#1
0
status_t
get_system_info(system_info* info)
{
	memset(info, 0, sizeof(system_info));

	info->boot_time = rtc_boot_time();
	info->cpu_count = smp_get_num_cpus();

	vm_page_get_stats(info);
	vm_get_info(info);

	info->used_threads = thread_used_threads();
	info->max_threads = thread_max_threads();
	info->used_teams = team_used_teams();
	info->max_teams = team_max_teams();
	info->used_ports = port_used_ports();
	info->max_ports = port_max_ports();
	info->used_sems = sem_used_sems();
	info->max_sems = sem_max_sems();

	info->kernel_version = kKernelVersion;
	strlcpy(info->kernel_name, kKernelName, B_FILE_NAME_LENGTH);
	strlcpy(info->kernel_build_date, __DATE__, B_OS_NAME_LENGTH);
	strlcpy(info->kernel_build_time, __TIME__, B_OS_NAME_LENGTH);
	info->abi = B_HAIKU_ABI;

	return B_OK;
}
示例#2
0
/* This is kind of approximate and works only with "localtime" */
int _gettimeofday_r(void * re, struct timeval *tv, struct timezone *tz) {
	uint32	m, s;
	
	assert( tv != NULL );

	timer_ms_gettime(&s, &m);
	tv->tv_sec = rtc_boot_time() + s;
	tv->tv_usec = m * 1000;

	return 0;
}
示例#3
0
void
RealTimeUserTimer::Schedule(bigtime_t nextTime, bigtime_t interval,
	uint32 flags, bigtime_t& _oldRemainingTime, bigtime_t& _oldInterval)
{
	InterruptsWriteSequentialLocker locker(sUserTimerLock);

	// get the current time
	bigtime_t now = system_time();

	// Cancel the old timer, if still scheduled, and get the previous values.
	if (fScheduled) {
		CancelTimer();

		_oldRemainingTime = fNextTime - now;
		_oldInterval = fInterval;

		if (fAbsolute) {
			SpinLocker globalListLocker(sAbsoluteRealTimeTimersLock);
			sAbsoluteRealTimeTimers.Remove(this);
		}

		fScheduled = false;
	} else {
		_oldRemainingTime = B_INFINITE_TIMEOUT;
		_oldInterval = 0;
	}

	// schedule the new timer
	fNextTime = nextTime;
	fInterval = interval;
	fOverrunCount = 0;

	if (nextTime == B_INFINITE_TIMEOUT)
		return;

	fAbsolute = (flags & B_RELATIVE_TIMEOUT) == 0;

	if (fAbsolute) {
		fRealTimeOffset = rtc_boot_time();
		fNextTime -= fRealTimeOffset;

		// If periodic, check whether the start time is too far in the past.
		if (fInterval > 0)
			CheckPeriodicOverrun(now);

		// add the absolute timer to the global list
		SpinLocker globalListLocker(sAbsoluteRealTimeTimersLock);
		sAbsoluteRealTimeTimers.Insert(this);
	} else
		fNextTime += now;

	ScheduleKernelTimer(now, false);
}
示例#4
0
/*!	Called when the real-time clock has been changed.

	The caller must hold \c sUserTimerLock. Optionally the caller may also
	hold \c sAbsoluteRealTimeTimersLock.
*/
void
RealTimeUserTimer::TimeWarped()
{
	ASSERT(fScheduled && fAbsolute);

	// get the new real-time offset
	bigtime_t oldRealTimeOffset = fRealTimeOffset;
	fRealTimeOffset = rtc_boot_time();
	if (fRealTimeOffset == oldRealTimeOffset)
		return;

	// cancel the kernel timer and reschedule it
	CancelTimer();

	fNextTime += oldRealTimeOffset - fRealTimeOffset;

	ScheduleKernelTimer(system_time(), fInterval > 0);
}