Exemplo n.º 1
0
	int LightWave::GetNumCores()
	{
#ifdef _MSWIN
		SYSTEM_INFO siSysInfo;
		GetSystemInfo(&siSysInfo);
		return siSysInfo.dwNumberOfProcessors;
#endif
#ifdef _MACOS
		return MPProcessors();
#endif
	}
Exemplo n.º 2
0
static inline guint
get_n_processors (void)
{
#ifdef __linux
	return sysconf(_SC_NPROCESSORS_ONLN);
	/* FIXME: add Mac/Windows implementations */
#elif __APPLE_CC__
        return MPProcessors ();
#else
	g_warning ("Your operating system is unsupported; you'll only get one core. "
		   "Feel free to fix this at " G_STRLOC);
	return 1;
#endif
}
Exemplo n.º 3
0
bool	CContentDownloader::Startup( const bool _bPreview, bool _bReadOnlyInstance )
{
	g_Log->Info( "Attempting to start contentdownloader...", _bPreview );
	Shepherd::initializeShepherd();

	Shepherd::setRedirectServerName( g_Settings()->Get( "settings.content.redirectserver", std::string(REDIRECT_SERVER) ).c_str() );
	
	std::string root = g_Settings()->Get( "settings.content.sheepdir", g_Settings()->Root() + "content" );
	
	if (root.empty())
	{
		root = g_Settings()->Root() + "content";
		g_Settings()->Set( "settings.content.sheepdir", root );
	}
	
	Shepherd::setRootPath( root.c_str() );
	Shepherd::setCacheSize( g_Settings()->Get( "settings.content.cache_size", 2000 ), 0 );
	Shepherd::setCacheSize( g_Settings()->Get( "settings.content.cache_size_gold", 2000 ), 1 );
	if (g_Settings()->Get( "settings.content.unlimited_cache", true) == true)
		Shepherd::setCacheSize( 0, 0 );
	if (g_Settings()->Get( "settings.content.unlimited_cache_gold", true) == true)
		Shepherd::setCacheSize( 0, 1 );
	Shepherd::setPassword( g_Settings()->Get( "settings.content.password_md5", std::string("") ).c_str() );
	Shepherd::setUniqueID( g_Settings()->Get( "settings.content.unique_id", generateID() ).c_str() );
	Shepherd::setUseProxy( g_Settings()->Get( "settings.content.use_proxy", false ) );
	Shepherd::setRegistered( g_Settings()->Get( "settings.content.registered", false ) );
	Shepherd::setProxy( g_Settings()->Get( "settings.content.proxy", std::string("") ).c_str() );
	Shepherd::setProxyUserName( g_Settings()->Get( "settings.content.proxy_username", std::string("") ).c_str() );
	Shepherd::setProxyPassword( g_Settings()->Get( "settings.content.proxy_password", std::string("") ).c_str() );

	Shepherd::setSaveFrames( g_Settings()->Get( "settings.generator.save_frames", false ) );
	SheepGenerator::setNickName( g_Settings()->Get( "settings.generator.nickname", std::string("") ).c_str() );
	SheepGenerator::setURL( g_Settings()->Get( "settings.generator.user_url", std::string("") ).c_str() );

    m_gDownloader = NULL;
		
	if( g_Settings()->Get( "settings.content.download_mode", true ) && _bReadOnlyInstance == false)
	{
		m_gDownloader = new SheepDownloader();
		g_Log->Info( "Starting download thread..." );
		m_gDownloadThread = new boost::thread( boost::bind( &SheepDownloader::shepherdCallback, m_gDownloader ) );
#ifdef WIN32
		SetThreadPriority( (HANDLE)m_gDownloadThread->native_handle(), THREAD_PRIORITY_BELOW_NORMAL );
		SetThreadPriorityBoost( (HANDLE)m_gDownloadThread->native_handle(), TRUE );
#else
		struct sched_param sp;
		sp.sched_priority = 6; //Background NORMAL_PRIORITY_CLASS - THREAD_PRIORITY_BELOW_NORMAL
		pthread_setschedparam( (pthread_t)m_gDownloadThread->native_handle(), SCHED_RR, &sp );
#endif
	}
	else
		g_Log->Warning( "Downloading disabled." );

	if( g_Settings()->Get( "settings.generator.enabled", true ) && _bReadOnlyInstance == false)
	{
		//	Create the generators based on the number of processors.
		uint32 ncpus = 1;
		if( g_Settings()->Get( "settings.generator.all_cores", false ) )
		{
#ifdef WIN32
			SYSTEM_INFO sysInfo;
			GetSystemInfo( &sysInfo );
			ncpus = (uint32)sysInfo.dwNumberOfProcessors;
#else
	#ifdef MAC
			ncpus = static_cast<uint32>(MPProcessors());
        #else
#ifdef LINUX_GNU
			ncpus = sysconf( _SC_NPROCESSORS_ONLN );
#endif
	#endif
#endif
		}

		if (ncpus > 1)
			--ncpus;
		uint32 i;
		for( i=0; i<ncpus; i++ )
		{
			g_Log->Info( "Starting generator for core %d...", i );
			gGenerators.push_back( new SheepGenerator() );
			gGenerators[i]->setGeneratorId( i );
		}

		g_Log->Info( "Starting generator threads..." );

		for( i=0; i<gGenerators.size(); i++ )
		{
			gGeneratorThreads.push_back( new boost::thread( boost::bind( &SheepGenerator::shepherdCallback, gGenerators[i] ) ) );
#ifdef WIN32
			SetThreadPriority( (HANDLE)gGeneratorThreads[i]->native_handle(), THREAD_PRIORITY_IDLE );
			SetThreadPriorityBoost( (HANDLE)gGeneratorThreads[i]->native_handle(), FALSE );
#else
			struct sched_param sp;
			sp.sched_priority = 1; //THREAD_PRIORITY_IDLE - THREAD_PRIORITY_IDLE
			pthread_setschedparam( (pthread_t)gGeneratorThreads[i]->native_handle(), SCHED_RR, &sp );
#endif
		}
	}
	else
		g_Log->Warning( "Generators disabled..." );

	g_Log->Info( "...success" );

	return true;
}
Exemplo n.º 4
0
int wxThread::GetCPUCount()
{
    return MPProcessors();
}
Exemplo n.º 5
0
/** @brief detects the OS Version
 *  @return String with OS Version.
 */
QString System::osVersionString(void)
{
    QString result;
#if defined(Q_OS_WIN32)
    SYSTEM_INFO sysinfo;
    OSVERSIONINFO osvi;
    ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    GetVersionEx(&osvi);
    GetSystemInfo(&sysinfo);

    result = QString("Windows version %1.%2, ").arg(osvi.dwMajorVersion).arg(osvi.dwMinorVersion);
    if(osvi.szCSDVersion)
        result += QString("build %1 (%2)").arg(osvi.dwBuildNumber)
            .arg(QString::fromWCharArray(osvi.szCSDVersion));
    else
        result += QString("build %1").arg(osvi.dwBuildNumber);
    result += QString("<br/>CPU: %1, %2 processor(s)").arg(sysinfo.dwProcessorType)
              .arg(sysinfo.dwNumberOfProcessors);
#endif
#if defined(Q_OS_LINUX) || defined(Q_OS_MACX)
    struct utsname u;
    int ret;
    ret = uname(&u);

#if defined(Q_OS_MACX)
    ItemCount cores = MPProcessors();
#else
    long cores = sysconf(_SC_NPROCESSORS_ONLN);
#endif
    if(ret != -1) {
        result = QString("CPU: %1, %2 processor(s)").arg(u.machine).arg(cores);
        result += QString("<br/>System: %2<br/>Release: %3<br/>Version: %4")
            .arg(u.sysname).arg(u.release).arg(u.version);
    }
    else {
        result = QString("(Error when retrieving system information)");
    }
#if defined(Q_OS_MACX)
    SInt32 major;
    SInt32 minor;
    SInt32 bugfix;
    OSErr error;
    error = Gestalt(gestaltSystemVersionMajor, &major);
    error = Gestalt(gestaltSystemVersionMinor, &minor);
    error = Gestalt(gestaltSystemVersionBugFix, &bugfix);

    result += QString("<br/>OS X %1.%2.%3 ").arg(major).arg(minor).arg(bugfix);
    // 1: 86k, 2: ppc, 10: i386
    SInt32 arch;
    error = Gestalt(gestaltSysArchitecture, &arch);
    switch(arch) {
        case 1:
        result.append("(86k)");
        break;
    case 2:
        result.append("(ppc)");
        break;
    case 10:
        result.append("(x86)");
        break;
    default:
        result.append("(unknown)");
        break;
    }
#endif
#endif
    result += QString("<br/>Qt version %1").arg(qVersion());
    return result;
}