本文整理汇总了C++中OperatingSystem类的典型用法代码示例。如果您正苦于以下问题:C++ OperatingSystem类的具体用法?C++ OperatingSystem怎么用?C++ OperatingSystem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OperatingSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: backing_stop_info_sp
bool
ThreadMemory::CalculateStopInfo ()
{
if (m_backing_thread_sp)
{
lldb::StopInfoSP backing_stop_info_sp (m_backing_thread_sp->GetPrivateStopInfo());
if (backing_stop_info_sp && backing_stop_info_sp->IsValidForOperatingSystemThread(*this))
{
backing_stop_info_sp->SetThread (shared_from_this());
SetStopInfo (backing_stop_info_sp);
return true;
}
}
else
{
ProcessSP process_sp (GetProcess());
if (process_sp)
{
OperatingSystem *os = process_sp->GetOperatingSystem ();
if (os)
{
SetStopInfo (os->CreateThreadStopReason (this));
return true;
}
}
}
return false;
}
示例2: experiment_result
Experiment_Result Experiment::copyback_map_experiment(vector<Thread*> (*experiment)(int highest_lba), int cb_map_min, int cb_map_max, int cb_map_inc, int used_space, string data_folder, string name, int IO_limit) {
Experiment_Result experiment_result(name, data_folder, "", "Max copyback map size");
experiment_result.start_experiment();
const int num_pages = NUMBER_OF_ADDRESSABLE_BLOCKS() * BLOCK_SIZE;
for (int copyback_map_size = cb_map_min; copyback_map_size <= cb_map_max; copyback_map_size += cb_map_inc) {
int highest_lba = (int) ((double) num_pages * used_space / 100);
printf("-------------------------------------------------------\n");
printf("Experiment with %d copybacks allowed in copyback map. \n", copyback_map_size);
printf("-------------------------------------------------------\n");
MAX_ITEMS_IN_COPY_BACK_MAP = copyback_map_size;
// Run experiment
vector<Thread*> threads = experiment(highest_lba);
OperatingSystem* os = new OperatingSystem();
os->set_threads(threads);
os->set_num_writes_to_stop_after(IO_limit);
os->run();
// Collect statistics from this experiment iteration (save in csv files)
experiment_result.collect_stats(copyback_map_size);
StatisticsGatherer::get_global_instance()->print();
if (PRINT_LEVEL >= 1) {
StateVisualiser::print_page_status();
StateVisualiser::print_block_ages();
}
delete os;
}
experiment_result.end_experiment();
return experiment_result;
}
示例3: CIMOperationFailedException
CIMObjectPath
OperatingSystemProvider::_fill_reference(const CIMNamespaceName &nameSpace,
const CIMName &className)
{
Array<CIMKeyBinding> keys;
OperatingSystem os;
String csName;
String name;
if (!os.getCSName(csName))
{
throw CIMOperationFailedException("OperatingSystemProvider "
"can't determine name of computer system");
}
if (!os.getName(name))
{
throw CIMOperationFailedException("OperatingSystemProvider "
"can't determine name of Operating System");
}
keys.append(CIMKeyBinding("CSCreationClassName",
CSCREATIONCLASSNAME.getString(),
CIMKeyBinding::STRING));
keys.append(CIMKeyBinding("CSName", csName, CIMKeyBinding::STRING));
keys.append(CIMKeyBinding("CreationClassName",
STANDARDOPERATINGSYSTEMCLASS.getString(),
CIMKeyBinding::STRING));
keys.append(CIMKeyBinding("Name", name, CIMKeyBinding::STRING));
return CIMObjectPath(csName, nameSpace, className, keys);
}
示例4: process_sp
lldb::StopInfoSP
ThreadMemory::GetPrivateStopReason ()
{
ProcessSP process_sp (GetProcess());
if (process_sp)
{
const uint32_t process_stop_id = process_sp->GetStopID();
if (m_thread_stop_reason_stop_id != process_stop_id ||
(m_actual_stop_info_sp && !m_actual_stop_info_sp->IsValid()))
{
// If GetGDBProcess().SetThreadStopInfo() doesn't find a stop reason
// for this thread, then m_actual_stop_info_sp will not ever contain
// a valid stop reason and the "m_actual_stop_info_sp->IsValid() == false"
// check will never be able to tell us if we have the correct stop info
// for this thread and we will continually send qThreadStopInfo packets
// down to the remote GDB server, so we need to keep our own notion
// of the stop ID that m_actual_stop_info_sp is valid for (even if it
// contains nothing). We use m_thread_stop_reason_stop_id for this below.
m_thread_stop_reason_stop_id = process_stop_id;
m_actual_stop_info_sp.reset();
OperatingSystem *os = process_sp->GetOperatingSystem ();
if (os)
m_actual_stop_info_sp = os->CreateThreadStopReason (this);
}
}
return m_actual_stop_info_sp;
}
示例5: mkdir
void Experiment::simple_experiment_double(string name, T* var, T min, T max, T inc) {
string data_folder = base_folder + name + "/";
mkdir(data_folder.c_str(), 0755);
Experiment_Result global_result(name, data_folder, "Global/", variable_name);
global_result.start_experiment();
T& variable = *var;
for (variable = min; variable <= max; variable += inc) {
printf("----------------------------------------------------------------------------------------------------------\n");
printf("%s : %s \n", name.c_str(), to_string(variable).c_str());
printf("----------------------------------------------------------------------------------------------------------\n");
string point_folder_name = data_folder + to_string(variable) + "/";
mkdir(point_folder_name.c_str(), 0755);
if (generate_trace_file) {
VisualTracer::init(data_folder);
} else {
VisualTracer::init();
}
write_config_file(point_folder_name);
Queue_Length_Statistics::init();
Free_Space_Meter::init();
Free_Space_Per_LUN_Meter::init();
OperatingSystem* os;
if (calibrate_for_each_point && calibration_workload != NULL) {
string calib_file_name = "calib-" + to_string(variable) + ".txt";
Experiment::calibrate_and_save(calibration_workload, calib_file_name);
os = load_state(calib_file_name);
} else if (!calibration_file.empty()) {
os = load_state(calibration_file);
} else {
os = new OperatingSystem();
}
if (workload != NULL) {
vector<Thread*> experiment_threads = workload->generate_instance();
os->set_threads(experiment_threads);
}
os->set_num_writes_to_stop_after(io_limit);
os->run();
StatisticsGatherer::get_global_instance()->print();
Utilization_Meter::print();
Queue_Length_Statistics::print_avg();
Free_Space_Meter::print();
Free_Space_Per_LUN_Meter::print();
global_result.collect_stats(variable, StatisticsGatherer::get_global_instance());
write_results_file(point_folder_name);
delete os;
}
global_result.end_experiment();
vector<Experiment_Result> result;
result.push_back(global_result);
results.push_back(result);
}
示例6: printf
OperatingSystem* Experiment::load_state(string name) {
string file_name = base_folder + name;
printf("loading calibration file: %s\n", file_name.c_str());
std::ifstream file(file_name.c_str());
boost::archive::text_iarchive ia(file);
ia.register_type<FtlImpl_Page>( );
ia.register_type<Block_manager_parallel>();
ia.register_type<Sequential_Locality_BM>( );
ia.register_type<File_Manager>( );
ia.register_type<Simple_Thread>( );
ia.register_type<Random_IO_Pattern>( );
ia.register_type<Sequential_IO_Pattern>( );
ia.register_type<WRITES>( );
ia.register_type<TRIMS>( );
ia.register_type<READS>( );
ia.register_type<READS_OR_WRITES>();
ia.register_type<Asynchronous_Random_Writer>();
ia.register_type<Asynchronous_Random_Reader>();
ia.register_type<MTRand>();
ia.register_type<MTRand_closed>();
ia.register_type<MTRand_open>();
ia.register_type<MTRand53>();
OperatingSystem* os;
ia >> os;
vector<Thread*> threads;
ia >> threads;
Individual_Threads_Statistics::init();
for (auto t : threads) {
//Individual_Threads_Statistics::register_thread(t, "");
}
os->set_threads(threads);
//os->init_threads();
IOScheduler* scheduler = os->get_ssd()->get_scheduler();
scheduler->init();
Block_manager_parent* bm = Block_manager_parent::get_new_instance();
bm->copy_state(scheduler->get_bm());
delete scheduler->get_bm();
scheduler->set_block_manager(bm);
Migrator* m = scheduler->get_migrator();
m->set_block_manager(bm);
Garbage_Collector* gc = m->get_garbage_collector();
gc->set_block_manager(bm);
return os;
}
示例7: coletaWin
void cacic_hardware::iniciaColeta()
{
#ifdef Q_OS_WIN
this->coletaHardware = coletaWin();
#elif defined(Q_OS_LINUX)
OperatingSystem operatingSystem;
// Como criaremos pacotes agora, todas essas verificações podiam só
// ser incluídas como dependências.
// se o shell retorna erro ao tentar utilizar o lshw ou o dmidecode, instala o mesmo
if( console("lshw").contains("/bin/sh:") ){
QLogger::QLog_Info("Gercols (hardware)", "lshw nao estava instalado.");
if(operatingSystem.getIdOs() == OperatingSystem::LINUX_ARCH)
console("pacman -S --needed --noconfirm lshw");
else if(operatingSystem.getIdOs() == OperatingSystem::LINUX_DEBIAN ||
operatingSystem.getIdOs() == OperatingSystem::LINUX_UBUNTU )
console("apt-get -y install lshw");
}
if( console("dmidecode").contains("/bin/sh:") ){
QLogger::QLog_Info("Gercols (hardware)", "dmidecode nao estava instalado");
if(operatingSystem.getIdOs() == OperatingSystem::LINUX_ARCH)
console("pacman -S --needed --noconfirm dmidecode");
else if(operatingSystem.getIdOs() == OperatingSystem::LINUX_DEBIAN ||
operatingSystem.getIdOs() == OperatingSystem::LINUX_UBUNTU )
console("apt-get -y install dmidecode");
}
this->coletaHardware = coletaLinux();
#endif
}
示例8: thread_sp
void
RegisterContextThreadMemory::UpdateRegisterContext ()
{
ThreadSP thread_sp (m_thread_wp.lock());
if (thread_sp)
{
ProcessSP process_sp (thread_sp->GetProcess());
if (process_sp)
{
const uint32_t stop_id = process_sp->GetModID().GetStopID();
if (m_stop_id != stop_id)
{
m_stop_id = stop_id;
m_reg_ctx_sp.reset();
}
if (!m_reg_ctx_sp)
{
ThreadSP backing_thread_sp (thread_sp->GetBackingThread());
if (backing_thread_sp)
{
m_reg_ctx_sp = backing_thread_sp->GetRegisterContext();
}
else
{
OperatingSystem *os = process_sp->GetOperatingSystem ();
if (os->IsOperatingSystemPluginThread (thread_sp))
m_reg_ctx_sp = os->CreateRegisterContextForThread (thread_sp.get(), LLDB_INVALID_ADDRESS);
}
}
}
else
{
m_reg_ctx_sp.reset();
}
}
else
{
m_reg_ctx_sp.reset();
}
}
示例9: ifile
// currently, this method checks if there if a file already exists, and if so, assumes it is valid.
// ideally, a check should be made to ensure the saved SSD state matches with the state of the current global parameters
void Experiment::calibrate_and_save(Workload_Definition* workload, string name, int num_IOs, bool force) {
//string file_name = base_folder + "calibrated_state.txt";
string file_name = base_folder + name;
std::ifstream ifile(file_name.c_str());
if (ifile && !force) {
return; // file exists
}
StatisticsGatherer::set_record_statistics(false);
//StatisticsGatherer::get_global_instance()->init();
Thread::set_record_internal_statistics(false);
VisualTracer::init();
//Free_Space_Meter::init();
//Free_Space_Per_LUN_Meter::init();
printf("Creating calibrated SSD state.\n");
OperatingSystem* os = new OperatingSystem();
os->set_num_writes_to_stop_after(num_IOs);
vector<Thread*> init_threads = workload->generate_instance();
os->set_threads(init_threads);
os->set_progress_meter_granularity(1000);
os->run();
os->get_ssd()->execute_all_remaining_events();
save_state(os, file_name);
//StatisticsGatherer::get_global_instance()->print();
//Free_Space_Meter::print();
//Free_Space_Per_LUN_Meter::print();
delete os;
}
示例10: CIMNotSupportedException
void
OperatingSystemProvider::getInstance(const OperationContext& context,
const CIMObjectPath& ref,
const Boolean includeQualifiers,
const Boolean includeClassOrigin,
const CIMPropertyList& propertyList,
InstanceResponseHandler &handler)
{
Array<CIMKeyBinding> keys;
CIMInstance instance;
OperatingSystem os;
CIMName className;
String csName;
String name;
//-- make sure we're working on the right class
className = ref.getClassName();
if (!(className.equal (STANDARDOPERATINGSYSTEMCLASS)) &&
!(className.equal (EXTENDEDOPERATINGSYSTEMCLASS)))
throw CIMNotSupportedException("OperatingSystemProvider does not support class " + className.getString());
//-- make sure we're the right instance
int keyCount;
CIMName keyName;
keyCount = 4;
keys = ref.getKeyBindings();
if ((unsigned int)keys.size() != (unsigned int)keyCount)
throw CIMInvalidParameterException("Wrong number of keys");
// doesn't seem as though this code will handle duplicate keys,
// but it appears as though the CIMOM strips those out for us.
// Despite test cases, don't get invoked with 2 keys of the same
// name.
if (!os.getCSName(csName))
{
throw CIMOperationFailedException("OperatingSystemProvider "
"Can't determine name of computer system");
}
if (!os.getName(name))
{
throw CIMOperationFailedException("OperatingSystemProvider "
"Can't determine name of Operating System");
}
for (unsigned int ii = 0; ii < keys.size(); ii++)
{
keyName = keys[ii].getName();
if ((keyName.equal ("CSCreationClassName")) &&
String::equalNoCase(keys[ii].getValue(),
CSCREATIONCLASSNAME.getString()))
{
keyCount--;
}
else if ((keyName.equal ("CSName")) &&
String::equalNoCase(keys[ii].getValue(), csName))
{
keyCount--;
}
else if ((keyName.equal ("CreationClassName")) &&
String::equalNoCase(keys[ii].getValue(),
STANDARDOPERATINGSYSTEMCLASS.getString()))
{
keyCount--;
}
else if ((keyName.equal ("Name")) &&
String::equalNoCase(keys[ii].getValue(), name))
{
keyCount--;
}
else
{
throw CIMInvalidParameterException("OperatingSystemProvider"
" unrecognized key " + keyName.getString());
}
}
if (keyCount)
{
throw CIMInvalidParameterException("Wrong keys");
}
OSP_DEBUG("losp-> getInstance got the right keys");
handler.processing();
//-- fill 'er up...
instance = _build_instance(ref);
instance.setPath(ref);
OSP_DEBUG("losp-> getInstance built an instance");
handler.deliver(instance);
handler.complete();
//.........这里部分代码省略.........
示例11: instance
CIMInstance
OperatingSystemProvider::_build_instance(const CIMObjectPath& objectReference)
{
CIMInstance instance(objectReference.getClassName());
OperatingSystem os;
CIMName className;
String stringValue;
Uint16 uint16Value;
CIMDateTime cimDateTimeValue;
Sint16 sint16Value;
Uint32 uint32Value;
Uint64 uint64Value;
Boolean booleanValue;
className = objectReference.getClassName();
//-- fill in all the blanks
instance.addProperty(CIMProperty("CSCreationClassName",
(CSCREATIONCLASSNAME.getString())));
if (os.getCSName(stringValue))
{
instance.addProperty(CIMProperty("CSName", stringValue));
}
instance.addProperty(CIMProperty("CreationClassName",
(STANDARDOPERATINGSYSTEMCLASS.getString())));
if (os.getName(stringValue))
{
instance.addProperty(CIMProperty("Name", stringValue));
}
if (os.getCaption(stringValue))
{
instance.addProperty(CIMProperty("Caption", stringValue));
}
if (os.getDescription(stringValue))
{
instance.addProperty(CIMProperty("Description", stringValue));
}
if (os.getInstallDate(cimDateTimeValue))
{
instance.addProperty(CIMProperty("InstallDate", cimDateTimeValue));
}
if (os.getStatus(stringValue))
{
instance.addProperty(CIMProperty("Status", stringValue));
}
if (os.getOSType(uint16Value))
{
instance.addProperty(CIMProperty("OSType", uint16Value));
}
if (os.getOtherTypeDescription(stringValue))
{
instance.addProperty(CIMProperty("OtherTypeDescription", stringValue));
}
if (os.getVersion(stringValue))
{
instance.addProperty(CIMProperty("Version", stringValue));
}
if (os.getLastBootUpTime(cimDateTimeValue))
{
instance.addProperty(CIMProperty("LastBootUpTime", cimDateTimeValue));
}
if (os.getLocalDateTime(cimDateTimeValue))
{
instance.addProperty(CIMProperty("LocalDateTime", cimDateTimeValue));
}
if (os.getCurrentTimeZone(sint16Value))
{
instance.addProperty(CIMProperty("CurrentTimeZone", sint16Value));
}
if (os.getNumberOfLicensedUsers(uint32Value))
{
instance.addProperty(CIMProperty("NumberOfLicensedUsers",uint32Value));
}
if (os.getNumberOfUsers(uint32Value))
{
instance.addProperty(CIMProperty("NumberOfUsers", uint32Value));
}
if (os.getNumberOfProcesses(uint32Value))
{
instance.addProperty(CIMProperty("NumberOfProcesses", uint32Value));
}
if (os.getMaxNumberOfProcesses(uint32Value))
{
//.........这里部分代码省略.........
示例12: executeOnTestCase
Verdict executeOnTestCase(string testCaseName) {
string testCaseInputFilename = generator->getTestCasesDir() + "/" + testCaseName + ".in";
os->limitExecutionTime(generator->getTimeLimit());
os->limitExecutionMemory(generator->getMemoryLimit());
ExecutionResult result = os->execute(testCaseName + "-submission-evaluation", submissionCommand, testCaseInputFilename, "_submission.out", "_error.out");
os->limitExecutionTime(0);
os->limitExecutionMemory(0);
if (result.exitStatus == 0) {
return Verdict::unknown();
}
vector<Failure> failures;
if (result.exitStatus & (1<<7)) {
int signal = WTERMSIG(result.exitStatus);
if (signal == SIGXCPU) {
return Verdict::timeLimitExceeded();
}
failures.push_back(Failure("Execution of submission failed:", 0));
failures.push_back(Failure(string(strsignal(signal)), 1));
} else {
failures.push_back(Failure("Execution of submission failed:", 0));
failures.push_back(Failure("Exit code: " + Util::toString(result.exitStatus), 1));
failures.push_back(Failure("Standard error: " + string(istreambuf_iterator<char>(*result.errorStream), istreambuf_iterator<char>()), 1));
}
return Verdict::runtimeError(failures);
}
示例13: scoreOnTestCase
Verdict scoreOnTestCase(string testCaseName) {
string testCaseOutputFilename = generator->getTestCasesDir() + "/" + testCaseName + ".out";
string diffCommand = "diff --unchanged-line-format=' %.2dn %L' --old-line-format='(expected) [line %.2dn] %L' --new-line-format='(received) [line %.2dn] %L' " + testCaseOutputFilename + " _submission.out | head -n 10";
ExecutionResult result = os->execute(testCaseName + "-submission-scoring", diffCommand, "", "_diff.out", "");
string briefDiffCommand = "diff --brief _submission.out " + testCaseOutputFilename;
ExecutionResult briefResult = os->execute(testCaseName + "-submission-scoring-brief", briefDiffCommand, "", "", "");
if (briefResult.exitStatus == 0) {
return Verdict::accepted();
} else {
string diff = string(istreambuf_iterator<char>(*result.outputStream), istreambuf_iterator<char>());
return Verdict::wrongAnswer({
Failure("Diff:\n" + diff, 0)
});
}
}
示例14: submitOnTestCase
Verdict submitOnTestCase(string testCaseName) {
if (!brief) {
logger->logTestCaseIntroduction(testCaseName);
}
Verdict verdict = gradeOnTestCase(testCaseName);
os->removeFile("_submission.out");
os->removeFile("_diff.out");
if (!brief) {
logger->logTestCaseVerdict(verdict);
}
if (!verdict.isAccepted()) {
if (!brief) {
logger->logFailures(verdict.getFailures());
}
}
return verdict;
}
示例15: evaluate
EvaluationResult evaluate(
const string& inputFilename,
const string& outputFilename,
const EvaluatorConfig& config) {
ExecutionRequestBuilder request = ExecutionRequestBuilder()
.setCommand(config.solutionCommand())
.setInputFilename(inputFilename)
.setOutputFilename(outputFilename)
.setErrorFilename("_error.out");
if (config.timeLimit()) {
request.setTimeLimit(config.timeLimit().value());
}
if (config.memoryLimit()) {
request.setMemoryLimit(config.memoryLimit().value());
}
ExecutionResult executionResult = os_->execute(request.build());
return createResult(executionResult);
}