/** Starts test step @internalComponent @return TVerdict pass / fail @pre N/A @post N/A */ enum TVerdict CT_WServCapCheckStepTSizeMode::runTestCaseL(const TDesC& aExecutable, const TInt& aExitReason) { __UHEAP_MARK; // mark the heap state //Launch window server client process read fron ini file RProcess process; User::LeaveIfError(process.Create(aExecutable, KNullDesC)); process.SetPriority(EPriorityHigh); TEST(process.Priority() == EPriorityHigh); INFO_PRINTF3(_L("Process Priority: Actual: %d, Expected: %d"), process.Priority(), EPriorityHigh); //Wait for the client process to terminate TRequestStatus status; process.Logon(status); process.Resume(); User::WaitForRequest(status); //Check the window server client exit reason INFO_PRINTF3(_L("Process Check: Actual: %d, Expected: %d"), process.ExitReason(), aExitReason); TEST(process.ExitReason() == aExitReason); __UHEAP_MARKEND; // check for no memory leak return TestStepResult(); }
EXPORT_C int setpriority( int which, int who, int value ) { int retval = -1; if((who == 0) && (which == PRIO_PROCESS )) { if(value > LOWER_LIMIT_PRIORITY_LOWEST) { value = LOWER_LIMIT_PRIORITY_LOWEST; } if(value < UPPER_LIMIT_PRIORITY_HIGHEST) { value = UPPER_LIMIT_PRIORITY_ABOVE_NORMAL; } int priority = convPri( value ); if( priority != -1 ) { RProcess pro; pro.SetPriority( convPri( value ) ); ProcPriority = value; retval = 0; } } //handling error case and not supported case if( retval == -1 ) { errno = ENOSYS; } return retval; }
TInt StartServer() { TRACE_STATIC_FUNC const TUid KKBTHIDSrvUid3 = { BTHID_SRV_UID }; const TUidType serverUid(KNullUid,KNullUid, KKBTHIDSrvUid3); RProcess server; TInt r = server.Create(KBTHidServerFilename, KNullDesC, serverUid); if (r != KErrNone) return r; server.SetPriority(EPriorityHigh); TRequestStatus stat; server.Rendezvous(stat); if (stat != KRequestPending) { server.Kill(0); } else { server.Resume(); } User::WaitForRequest(stat); TRACE_INFO((_L("[BTHID] Server started, code %d"), stat.Int())) r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int(); server.Close(); return r; }
TInt LaunchServer(RProcess& aServer) { TheTest.Printf(_L("Launching LogServer...\n")); const TUid KServerUid3 = {0x0101f401d}; const TUidType serverUid(KNullUid,KNullUid,KServerUid3); TInt err = aServer.Create(KServerProcess, _L(""),serverUid); if(err == KErrNone) { aServer.SetPriority(EPriorityForeground); //Start server and wait until it is running TRequestStatus serverStat; aServer.SetJustInTime(false); aServer.Resume(); aServer.Rendezvous(serverStat); User::WaitForRequest(serverStat); } return err; }
void SetPriority() { RProcess processHandle; __LOGSTR("Set process priority"); processHandle.SetPriority(EPriorityHigh); processHandle.Close(); }
/** Function : CT_MsgServer Description : Constructor @return : N/A */ CT_MsgServer::CT_MsgServer() : CTestServer() , iSharedDataBase(NULL) , iActiveScheduler(NULL) { //Raise process priority to allow complete event logging. RProcess me; me.SetPriority(TProcessPriority(450)); User::SetPriorityControl(EFalse); }
// ========================================================================== // Server process entry-point // ========================================================================== TInt E32Main() { // Set the priority of this process to slightly higher than background, in order to give the // UI the highest priority. RProcess myProcess; myProcess.SetPriority( EPriorityBackground ); RThread myThread; myThread.SetPriority( EPriorityMore ); TInt returnValue = MessageStoreServerThreadFunction( (TAny*)ETrue ); return returnValue; } // end E32Main
//All child process creation void CSMPSoakThread::CreateChildProcess(TInt aIndex) { if(TestSilent) gCmdLine.Format(KCmdLineBackground,(KProcessTable[aIndex].operation).Ptr()); else if (Period) gCmdLine.Format(KCmdLinePeriod,gPeriod,(KProcessTable[aIndex].operation).Ptr()); else gCmdLine.Format(KCmdLineProcess,(KProcessTable[aIndex].operation).Ptr()); TInt r = iProcess.Create(KProcessTable[aIndex].processFileName,gCmdLine); test_KErrNone(r); iProcess.SetPriority(EPriorityLow); gSMPStressDrv.ChangeThreadAffinity(&iThread, KProcessTable[aIndex].cpuAffinity); PRINT ((_L("SetProcessPriority CPU %d Priority %d\n"),gSMPStressDrv.GetThreadCPU(&iThread), iProcess.Priority())); }
// ----------------------------------------------------------------------------- // RDosServer::StartServer // Creates the server thread/process // ----------------------------------------------------------------------------- EXPORT_C TInt RDosServer::StartServer() const { API_TRACE_( "[DOSSERVER] RDosServer::StartServer()" ); TInt ret(KErrNone); TRequestStatus status; // IPCv2: TSignal no longer used, but still passed to threadfunction as // otherwise API change would be required. CDosServer::TSignal signal( status ); // Create startup semaphore RSemaphore startupSemaphore; ret = startupSemaphore.CreateGlobal( KServerStartupSemaphoreName, 0 ); if ( ret == KErrAlreadyExists ) { // The server is starting up, but has not yet started startupSemaphore.OpenGlobal( KServerStartupSemaphoreName ); startupSemaphore.Wait(); // wait until the server has started up. startupSemaphore.Close(); return ret; } // launch server thread (emulator) or process (Target platform) RProcess server; ret = server.Create( KDosServerExe, signal.Get(), TUidType( KNullUid, KNullUid, KDosServerUid ), EOwnerThread ); if ( ret ) { startupSemaphore.Close(); return ret; } server.SetPriority(EPriorityHigh); server.Resume(); server.Close(); startupSemaphore.Wait(); startupSemaphore.Close(); return KErrNone; }
// ----------------------------------------------------------------------------- // Function that starts the test process. // ----------------------------------------------------------------------------- // static void RunServerL( const TDesC &aParameter ) { COMPONENT_TRACE( ( _L( "SenSrvTestProcess - RunServerL(name=%S)" ),&aParameter ) ); TInt processID( 0 ); TLex parameter( aParameter ); parameter.Val( processID ); TTime now; now.HomeTime(); TBuf<50> processName; processName.Format( KSensrvTestProcessName, now.Int64() ); User::RenameProcess( processName ); // Set process priority RProcess svrProcess; svrProcess.SetPriority( EPriorityHigh ); // Create and install the active scheduler we need CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; CleanupStack::PushL(scheduler); CActiveScheduler::Install( scheduler ); CSensrvTestObserver* observer = CSensrvTestObserver::NewLC( processID ); // Initialisation complete, now signal the client RProcess::Rendezvous(KErrNone); // Ready to run COMPONENT_TRACE( ( _L( "SenSrvTestProcess - RunServer() - Starting scheduler..." )) ); CActiveScheduler::Start(); COMPONENT_TRACE( ( _L( "SenSrvTestProcess - RunServer() - Scheduler stopped" )) ); // Cleanup CleanupStack::PopAndDestroy(observer); CleanupStack::PopAndDestroy(scheduler); COMPONENT_TRACE( ( _L( "SenSrvTestProcess - RunServer() - return" )) ); }
// ----------------------------------------------------------------------------- // CSearchServer::ConstructL() // Symbian 2nd phase constructor can leave. // ----------------------------------------------------------------------------- // void CSearchServer::ConstructL() { OstTraceFunctionEntry0( CSEARCHSERVER_CONSTRUCTL_ENTRY ); CPIXLOGSTRING("Creating search server"); RProcess process; process.SetPriority( EPriorityBackground ); process.Close(); // Create new container index iContainerIndex = CObjectConIx::NewL(); // Create new house keeping handler iHouseKeepingHandler = CHouseKeepingHandler::NewL(); iHouseKeepingHandler->StartL(); // Initialize the OpenC search CCPixIdxDb::InitializeL(); StartL(KSearchServerName); OstTraceFunctionExit0( CSEARCHSERVER_CONSTRUCTL_EXIT ); }
void CMdSServer::ConstructL() { __INIT_LOGGER; StartL( KMdSServerName ); __LOGLB( ELogAlways, "Server start" ); RProcess process; process.SetPriority( EPriorityBackground ); process.Close(); CheckInitSriptL(); iLockList = CMdSObjectLockList::NewL(); CMdSSqLiteConnection* conn = CMdSSqLiteConnection::NewLC(); iDefaultDBConnection = conn; MMdSDbConnectionPool::SetDefaultDB( conn ); CleanupStack::Pop( conn ); CMdSMaintenanceEngine::InitConnectionL(); iNotifier = CMdSNotifier::NewL(); InitializeL(); iDiskSpaceGarbageCollectorNotifier = CMdSDiskSpaceNotifierAO::NewL( *this, KDiskSpaceGarbageCollectorThreshold, KMdsSqlDbDefaultName ); iDiskFullNotifier = CMdSDiskSpaceNotifierAO::NewL( *this, KDiskFullThreshold, KMdsSqlDbDefaultName ); // Create a backup & restore watcher and add this server as its observer. iBURWatcher = CMdEBackupRestoreWatcherAO::NewL(*this); // create shutdown observer iShutdownObserver = CMDSShutdownObserver::NewL( *this ); iShutdown = EFalse; }
/*! * Connect to / create a cntsrv server session */ void CntSymbianSrvConnection::ConnectSrvL() { // Assume the server is already running and attempt to create a session // with a maximum of KAsyncMessageSlots message slots. TInt err = CreateSession(KCntServerName,Version(),KAsyncMessageSlots); // Server is not running if(err == KErrNotFound) { // Use the RProcess API to start the server. RProcess server; User::LeaveIfError(server.Create(KCntServerExe,KNullDesC)); //Enforce server to be at system default priority EPriorityForeground server.SetPriority(EPriorityForeground); // Synchronize with the server. TRequestStatus reqStatus; server.Rendezvous(reqStatus); server.Resume(); // Server will call the reciprocal static synchronization call. User::WaitForRequest(reqStatus); server.Close(); User::LeaveIfError(reqStatus.Int()); // Create the server session. User::LeaveIfError(CreateSession(KCntServerName,Version(),KAsyncMessageSlots)); } else { User::LeaveIfError(err); } // Create IPC buffer m_buffer = CBufFlat::NewL(1 << KGranularityRank); m_maxBufferSize = KDefaultPackagerSize; }
void CCmdSetpriority::DoRunL() { LoadMemoryAccessL(); TInt err = KErrNone; // Fix up priorities that we had to make different to kernel cos fshell can't handle negative arguments // See enum TThrdPriority in kern_priv.h for the meaning of these negative numbers switch(iPriority) { case 101: iPriority = -8; break; case 102: iPriority = -7; break; case 103: iPriority = -6; break; case 104: iPriority = -5; break; case 105: iPriority = -4; break; case 106: iPriority = -3; break; case 107: iPriority = -2; break; default: break; } if (iName) { TPtrC8 name8 = iName->Des().Collapse(); LeaveIfErr(iMemAccess.SetPriorityOverride(iPriority, name8), _L("Couldn't set priority override")); iNotifier = new(ELeave) CNewThreadNotifier(*this, iMemAccess); iNotifier->Start(); return; } if (iTids.Count() && iPids.Count()) { LeaveIfErr(KErrArgument, _L("You cannot specify both --tid and --pid - a single priority cannot be valid for thread and process.")); } for (TInt i = 0; i < iTids.Count(); i++) { TUint id = iTids[i]; RThread thread; err = iMemAccess.RThreadForceOpen(thread, id); if (!err) err = iMemAccess.SetThreadPriority(thread, iPriority); if (err) PrintError(err, _L("Couldn't set priority for thread %u"), id); thread.Close(); } for (TInt i = 0; i < iPids.Count(); i++) { TUint id = iPids[i]; // Get KProcessFlagPriorityControl flag RProcess process; err = process.Open(id); LeaveIfErr(err, _L("Couldn't open process with ID %u"), id); TBool priorityControlAllowed = EFalse; TPckg<TProcessKernelInfo> pkg(iProcInfo); err = iMemAccess.GetObjectInfoByHandle(EProcess, RThread().Id(), process.Handle(), pkg); if (err) { PrintWarning(_L("Couldn't get priority control flag setting (%d)\r\n"), err); } else { if (iProcInfo.iFlags & KProcessFlagPriorityControl) priorityControlAllowed = ETrue; } if (!priorityControlAllowed) { PrintError(KErrAccessDenied, _L("This process does not allow setting of its priority")); } else if (iPriority != EPriorityBackground && iPriority != EPriorityForeground) { PrintError(KErrAccessDenied, _L("The kernel will ignore requests to set a process priority that isn't Background (250) or Foreground (350). I can't see how to get round this even using memory access. Sorry.")); } process.SetPriority((TProcessPriority)iPriority); process.Close(); } Complete(KErrNone); }
// ----------------------------------------------------------------------------- // RPhCltServer::StartServer // // Launches the phone server, which is assumed to be not // already running. // ----------------------------------------------------------------------------- // TInt RPhCltServer::StartServer() { // The uid of the DLL/EXE - used to identify the correct target const TUidType KPhServerUidType( KExecutableImageUid, KSharedLibraryUid, KPhCltServerUid ); ////////////////////////////////////////////////////////////////////////// // On MARM, the server is an exe, so it is run inside its own process. // The server itself takes care of creating a thread and finalizing the // construction of the server. We pass the signalling object via the // command line. ////////////////////////////////////////////////////////////////////////// RProcess serverUnitOfExecution; TFileName pathName( KPhCltServerZDrive ); pathName.Append( KDC_PROGRAMS_DIR ); pathName.Append( KPhServerPathAndNameMARM ); pathName.ZeroTerminate(); TInt err = serverUnitOfExecution.Create( pathName, KNullDesC, KPhServerUidType ); if ( err != KErrNone ) { User::Panic( PH_SRV_SU_FAILURE, err ); } serverUnitOfExecution.SetPriority( EPriorityHigh ); // Now wait for the server to start up, and also observe if the server // thread dies for any reason. TRequestStatus stat; serverUnitOfExecution.Rendezvous( stat ); if ( stat != KRequestPending ) { User::Panic( PH_SRV_SU_FAILURE, EPhSrvStartupFailurePhase1 ); serverUnitOfExecution.Kill( KErrAbort ); // abort startup } else { serverUnitOfExecution.Resume(); // logon ok } // wait for start or death User::WaitForRequest( stat ); // we can't use the 'exit reason' if the server panicked as this // is the panic 'reason' and may be '0' which cannot be distinguished // from KErrNone err = ( serverUnitOfExecution.ExitType() == EExitPanic ) ? KErrGeneral : stat.Int(); serverUnitOfExecution.Close(); return err; }