示例#1
0
int
pthread_suspend_np(pthread_t thread)
{
	int		ret	= -1;
	pthread_t	pthread;

	PTHREAD_INIT;

	/*
	 * Search for the thread in the linked list.
	 */
	for (pthread = _thread_link_list; pthread != NULL && ret == -1; pthread = pthread->nxt) {
		/* Is this the thread? */
		if (pthread == thread) {
			/* Found the thread. Is it running? */
			if (pthread->state != PS_RUNNING &&
				pthread->state != PS_SUSPENDED) {
			    /* The thread operation has been interrupted */
			    _thread_seterrno(pthread,EINTR);
			} else 
			if (pthread->state == PS_RUNNING) 
			    DosSuspendThread(pthread->threadid);

			/* Suspend the thread. */
			PTHREAD_NEW_STATE(pthread,PS_SUSPENDED);
			ret = 0;
		}
	}
	/* Check if thread was not found. */
	if (ret == -1) {
		/* No such thread */
		errno = ESRCH;
	}
	return(ret);
}
/*--------------------------------------------------
 * Suspend the thread
 *-------------------------------------------------*/
PMThread& PMThread::suspend()
{
  if( run_id != -1 )
  {
    APIRET rc = DosSuspendThread( run_id );

    if( rc != NO_ERROR )
      PM_THROW_OS2ERROR(rc);
  }
  return *this;
}
示例#3
0
void
_PR_MD_SUSPEND_THREAD(PRThread *thread)
{
    if (_PR_IS_NATIVE_THREAD(thread)) {
       APIRET rc;

        /* XXXMB - DosSuspendThread() is not a blocking call; how do we
         * know when the thread is *REALLY* suspended?
         */
       rc = DosSuspendThread(thread->md.handle);
       PR_ASSERT(rc == NO_ERROR);
    }
}
示例#4
0
void
_thread_kern_sched_state(enum pthread_state state, char *fname, int lineno)
{
	PTHREAD_INIT;

	/* Change the state of the current thread: */
	_thread_run->state = state;
	_thread_run->fname = fname;
	_thread_run->lineno = lineno;

	switch (state) {
		case PS_MUTEX_WAIT:
		case PS_COND_WAIT:
		case PS_SUSPENDED:
			DosSuspendThread(_thread_run->threadid);
			break;
		default:
			DosSleep(1);
			break;
	}			

	return;
}
示例#5
0
BOOL ChangeWPS(PCHAR pszUserIni, PCHAR pszSystemIni)
   {
   PCHAR        pcEnv;
   PRFPROFILE   prfProfile;
   BOOL         bSuccess;

   if (*pszSystemIni == '\0')
      prfProfile.pszSysName = pShareInitOS2->pszRootSystemIni;
   else
      prfProfile.pszSysName = pszSystemIni;

   if (*prfProfile.pszSysName == '\0')
      prfProfile.pszSysName = (DosScanEnv (ENV_SYSTEM_INI, &pcEnv) ? "" : pcEnv);

   if (*pszUserIni == '\0')
      {
      prfProfile.pszUserName = pShareInitOS2->pszRootUserIni;
      pShareInitOS2->ulFlag  = pShareInitOS2->ulFlag_Root; // ulFlag f�r Rootdesktop
      }
   else
      prfProfile.pszUserName = pszUserIni;

   if (*prfProfile.pszUserName == '\0')
      prfProfile.pszUserName = (DosScanEnv (ENV_USER_INI, &pcEnv) ? "" : pcEnv);

   prfProfile.cchUserName = strlen(prfProfile.pszUserName);
   prfProfile.cchSysName  = strlen(prfProfile.pszSysName);

   if (ulOldFlag & CLOSEAPPL)
      WinSetObjectData(WinQueryObject("<WP_DESKTOP>"), "WORKAREA=YES");
   else
      WinSetObjectData(WinQueryObject("<WP_DESKTOP>"), "WORKAREA=NO");

   WinPostMsg(WinQueryWindow(HWND_DESKTOP, QW_BOTTOM), WM_CLOSE, 0, 0);
   DebugS (1, "HWND_DESKTOP closed");

   if( hevPrfResetLock )
      {
      DosWaitEventSem (hevPrfResetLock, SEM_INDEFINITE_WAIT);
      DosSleep(1000);
      DebugS (1, "hevPrfResetLock released");
      }
   else
      DosSleep(20000);

   bSuccess = PrfReset(hab, &prfProfile);
   DebugULd (1, "PrfReset", "return", bSuccess);

/*
 *  Beim Umschalten auf den Root, egal ob von Sammy oder von WPSamF ausgel�st,
 *  wird die Shell vom PrfReset nicht geschlossen.
 *  Solange die Ursache nicht bekannt ist, bleibt nichts anderes �brig,
 *  als an dieser Stelle symptomatisch vorzugehen und die Shell abzuschie�en.
 */
   if (*pszUserIni == '\0')
      {
      DosSuspendThread (tid1);
      DosKillProcess( DKP_PROCESSTREE, ulShellID );   // sog. Budnik'scher Arschtritt
      DebugS (1, "Shell killed");
      DosResumeThread (tid1);
      }

   if( !bSuccess )
      {
      WinSetObjectData(WinQueryObject("<WP_DESKTOP>"), "OPEN=ICON;WORKAREA=YES");
      DebugS (1, "Desktop set to <WP_DESKTOP>");
      intSammyRetCode = 250;
      WinPostQueueMsg (hmq, WM_QUIT, 0L, 0L);
      }
   else
      ulOldFlag = pShareInitOS2->ulFlag;

   return( bSuccess );
   }