Skip to content

Commit

Permalink
fix hyper-threading
Browse files Browse the repository at this point in the history
  • Loading branch information
mastercoms committed Sep 2, 2020
1 parent 0854390 commit 4086307
Show file tree
Hide file tree
Showing 16 changed files with 1,510 additions and 1,479 deletions.
3 changes: 1 addition & 2 deletions datacache/datacache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,7 @@ int CDataCacheSection::BeginFrameLocking()
{
while ( ( pFrameLock = m_FreeFrameLocks.Pop() ) == NULL )
{
ThreadPause();
ThreadSleep( 1 );
ThreadSleepEx( 1 );
}
pFrameLock->m_iLock = 1;
pFrameLock->m_pFirst = NULL;
Expand Down
2 changes: 1 addition & 1 deletion engine/audio/private/snd_dma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6576,7 +6576,7 @@ void S_Update_Thread()
// try to maintain a steadier rate by compensating for fluctuating mix times
// leave 1 ms for tighter timings in loop
const int nSleepMS = (int) ((THREADED_MIX_TIME - dt) * 1000);
if ( nSleepMS > 0 )
if ( nSleepMS >= 0 )
{
ThreadSleep( nSleepMS );
}
Expand Down
4 changes: 2 additions & 2 deletions engine/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ ConVar host_speeds( "host_speeds","0", 0, "Show general system running times." )
ConVar host_flush_threshold( "host_flush_threshold", "20", 0, "Memory threshold below which the host should flush caches between server instances" );

void HostTimerSpinMsChangedCallback( IConVar *var, const char *pOldString, float flOldValue );
ConVar host_timer_spin_ms( "host_timer_spin_ms", "0", FCVAR_NONE, "Use CPU busy-loop for improved timer precision (dedicated only)", HostTimerSpinMsChangedCallback );
ConVar host_timer_spin_ms( "host_timer_spin_ms", "2", FCVAR_NONE, "Use CPU busy-loop for improved timer precision (dedicated only)", HostTimerSpinMsChangedCallback );

void HostTimerSpinMsChangedCallback( IConVar *var, const char *pOldString, float flOldValue )
{
Expand Down Expand Up @@ -3962,7 +3962,7 @@ bool DLL_LOCAL Host_IsValidSignature( const char *pFilename, bool bAllowUnknown
while ( !Steam3Client().SteamUtils()->IsAPICallCompleted(hAPICall, &bAPICallFailed) )
{
SteamAPI_RunCallbacks();
ThreadSleep( 1 );
ThreadSleepEx( 1 );
}

if( bAPICallFailed )
Expand Down
4 changes: 2 additions & 2 deletions engine/sys_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,12 @@ void CEngine::Frame( void )
int nSleepMS = (int)((m_flMinFrameTime - m_flFrameTime) * 1000 - fBusyWaitMS);
if ( nSleepMS > 3 )
{
ThreadSleep(nSleepMS);
ThreadSleepEx(nSleepMS);
}

while (Plat_FloatTime() < fWaitEnd)
{
ThreadSleep();
ThreadSleepEx();
}

// Go back to the top of the loop and see if it is time yet.
Expand Down
2 changes: 1 addition & 1 deletion game/client/youtubeapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class CYouTubeJob : public CJob
// Wait for it to finish.
while ( m_bHTTPRequestPending && !m_bCancelled )
{
ThreadSleep( 100 );
ThreadSleepEx( 100 );
}

GetISteamHTTP()->ReleaseHTTPRequest( hSteamAPICall );
Expand Down
4 changes: 2 additions & 2 deletions game/server/tf/workshop/maps_workshop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ void CTFMapsWorkshop::PrepareLevelResources( /* in/out */ char *pszMapName, size
TFWorkshopMsg( "Waiting for steam connection\n" );
while ( !steamgameserverapicontext->SteamGameServer()->BLoggedOn() )
{
ThreadSleep( 10 );
ThreadSleepEx( 10 );
}
}
}
Expand All @@ -663,7 +663,7 @@ void CTFMapsWorkshop::PrepareLevelResources( /* in/out */ char *pszMapName, size
while ( AsyncPrepareLevelResources( pszMapName, nMapNameSize, pszMapFile, nMapFileSize ) == \
IServerGameDLL::ePrepareLevelResources_InProgress )
{
ThreadSleep( 10 );
ThreadSleepEx( 10 );
if ( engine->IsDedicatedServer() )
{
SteamGameServer_RunCallbacks();
Expand Down

0 comments on commit 4086307

Please sign in to comment.