explicit CorrelatedData(double ini) : gen_(ini) { init_(); }
Esempio n. 2
0
			inflate_reader_imp(io::read_map& src_, zip_format format, long_size_t uncompressed_size_, dict_type dict_, heap* h)
				: map_src(&src_), dict(dict_)
				, uncompressed_size(uncompressed_size_)
			{
				init_(dict_, h, format);
			}
	dstu4145_random_t::dstu4145_random_t(BYTE const * const seed_bonus, size_t const seed_bonus_size)
		: m_ctx(0)
	{
		init_(seed_bonus, seed_bonus_size);
	}
Esempio n. 4
0
void TiledLevelArray::reset() {
	if (_w!=0 && _h!=0) {
		free_();
		init_();
	}
}
Esempio n. 5
0
TriangleWrapper::TriangleWrapper(const Mesh & inMesh) : inMesh_(& inMesh){
    init_();
}
void
librandom::PoissonRandomDev::set_lambda( double lambda )
{
  mu_ = lambda;
  init_();
}
int main() {
    clock_t ticks;
    time_t start_time, end_time;
    time(&start_time);
    int i;
    int status = 0;
    log_file = fopen("log_file.txt", "w+");
    if (log_file == NULL) {
        fprintf(stderr, "LOG FILE CANNOT BE OPEN\n");
    }
    // initialize cpus
    for (i = 0; i < NUMBER_OF_PROCESSORS; i++) {
        CPU[i] = NULL;
    }
    init_();
    initializeProcessQueue(&readyQueue);
    initializeProcessQueue(&waitingQueue);

    // read in process and initialize process values
    while ((status = (readProcess(&processes[number_of_processes])))) {
        if (status == 1) {
            number_of_processes++;
        }
        if (number_of_processes > MAX_PROCESSES || number_of_processes == 0) {
            break;
        }
    }
    //sort process by their arrival times
    qsort(processes, number_of_processes, sizeof (process), compareByArrival);
    // main execution loop
    while (TRUE) {
        ticks = clock();
        incoming_process_init();
        running_process_to_waiting();
        most_ready_running_in_cpu();
        waiting_to_ready();

        refresh_processes();

        cpu_utilized_time += runningProcesses();
		simulation_time++;
        // break when there are no more running or incoming processes, and the waiting queue is empty
        if (runningProcesses() == 0 && (number_of_processes - nextProcess) == 0 && waitingQueue.size == 0) {
			break;
        }
    }
    // calculations based on CPU simulations
    int total_waiting_time = 0;
    int turn_around_time = 0;
    for (i = 0; i < number_of_processes; i++) {
        turn_around_time += processes[i].endTime - processes[i].arrivalTime;
        total_waiting_time += processes[i].waitingTime;
    }
    printf("********************************************************************\n");
    printf("Average Waiting Time\t\t\t:%.2f\n", total_waiting_time / (double) number_of_processes);
    printf("Average Turn Around Time\t\t:%.2f\n", turn_around_time / (double) number_of_processes);
    printf("Time all for all CPU processes\t\t:%d\n", simulation_time);
    printf("CPU Utilization Time\t\t\t:%.2f%c\n", (double) (cpu_utilized_time * 100.0) / (double) (simulation_time), (int) 37);
    printf("Total Number of Context Switches\t:%d\n", context_switches);
    printf("Last Process to finish ");
    for (i = 0; i < number_of_processes; i++) {
        if (processes[i].endTime == last_process_end_time) {
            printf("PID\t\t:%d\n", processes[i].pid);
        }
    }
	//printf("%d\n" , processes[number_of_processes].pid);
    printf("********************************************************************\n");
    time(&end_time);
    double prg_time = (end_time - start_time) * 0.001;
    double cpu_time = (double) ticks / CLOCKS_PER_SEC;
    fprintf(log_file, "Program Time\t:%.2fsecs\n", prg_time);
    fprintf(log_file, "CPU Time\t:%.2fsecs\n", cpu_time);
    fclose(log_file);
    return 0;
}
Esempio n. 8
0
librandom::PoissonRandomDev::PoissonRandomDev(RngPtr r_source, 
				double lambda)
  : RandomDev(r_source), mu_(lambda), P_(n_tab_)
{
  init_();
}
Esempio n. 9
0
JWA::JWA(const std::string &json): _{new JWAImpl{json}}, valid_{false}  {
    init_();
}
Esempio n. 10
0
JWA::JWA(void *_): _{new JWAImpl{_}}, valid_{false} {
    init_();
}
void rice::pastry::socket::nat::rendezvous::RendezvousSocketPastryNodeFactory::ctor(::rice::pastry::NodeIdFactory* nf, int32_t startPort, ::rice::environment::Environment* env, bool firewalled) /* throws(IOException) */
{
    super::ctor(nf, startPort, env);
    init();
    init_(firewalled);
}
Esempio n. 12
0
EclipseGridInspector::EclipseGridInspector(Opm::DeckConstPtr deck)
    : deck_(deck)
{
    init_();
}
Esempio n. 13
0
 SpecInfo::SpecInfo(SpecialistTypes specialistType, PlayerTypes playerType) : specialistType_(specialistType), playerType_(playerType)
 {
     init_();
 }
Esempio n. 14
0
inline Pattern::Pattern(char const* pattern, unsigned flags)
    : m_hCompiledPattern(init_(pattern, flags, m_numMatches))
{}
Esempio n. 15
0
void
audio_resampler_acm::close( void )
{


    MMRESULT err;


    if ( acm_stream )
    {

        if ( acm_header.fdwStatus & ACMSTREAMHEADER_STATUSF_PREPARED )
        {

            acm_header.cbSrcLength = src_buflen;
            acm_header.cbDstLength = dst_buflen;

            err = acmStreamUnprepareHeader( acm_stream, &acm_header, 0L );

        
            if ( err != MMSYSERR_NOERROR )
            {
            
                //
                // Free buffer memory
                //

                if ( acm_header.pbSrc != 0 )
                    delete[] acm_header.pbSrc;

                if ( acm_header.pbDst != 0 )
                    delete[] acm_header.pbDst;


                //
                // Re-init structures
                //

                init_();

                //
                // Updating status
                //

                stream_opened = false;


                //TODO: throw error
                MessageBox( 0, _T("acmStreamUnPrepareHeader error"), _T("ERROR"), MB_ICONERROR );

            
            }
        }


        err = acmStreamClose( acm_stream, 0 );
        acm_stream = 0;

        if ( err != MMSYSERR_NOERROR )
        {

            //
            // Free buffer memory
            //

            if ( acm_header.pbSrc != 0 )
                delete[] acm_header.pbSrc;

            if ( acm_header.pbDst != 0 )
                delete[] acm_header.pbDst;


            //
            // Re-init structures
            //

            init_();


            //
            // Updating status
            //

            stream_opened = false;


            //TODO: throw error!

            MessageBox( 0, _T("acmStreamClose error"), _T("ERROR"), MB_ICONERROR );


        }


    }//if acm_stream != 0






    //
    // Free buffer memory
    //

    if ( acm_header.pbSrc != 0 )
        delete[] acm_header.pbSrc;

    if ( acm_header.pbDst != 0 )
        delete[] acm_header.pbDst;


    //
    // Re-init structures
    //

    init_();


    //
    // Updating status
    //

    stream_opened = false;



    //
    // ACM sream successfully closed.
    //


}
Esempio n. 16
0
inline Pattern::Pattern(slice_t const& pattern, unsigned flags)
    : m_hCompiledPattern(init_(&pattern, flags, m_numMatches))
{}
Esempio n. 17
0
void
ConnectionManager::init( Dictionary* synapsedict )
{
  synapsedict_ = synapsedict;
  init_();
}
Esempio n. 18
0
librandom::PoissonRandomDev::PoissonRandomDev(double lambda)
  : RandomDev(), mu_(lambda), P_(n_tab_)
{
  init_();
}
Esempio n. 19
0
void
Restore::operator()()
{
    LOG_INFO("Starting the Restore");

    bpt::ptree total_pt;
    bpt::json_parser::read_json(configuration_file_.string(),
                                total_pt);

    init_(total_pt);

    const bpt::ptree& target_pt = total_pt.get_child("target_configuration");

    be::BackendConnectionManagerPtr
        target_cm(be::BackendConnectionManager::create(target_pt,
                                                       RegisterComponent::F));

    const std::string target_nspace(target_pt.get<std::string>("namespace"));

    be::BackendInterfacePtr
        target_bi(target_cm->newBackendInterface(backend::Namespace(target_nspace)));

    const boost::optional<bpt::ptree&>
        maybe_source_pt(total_pt.get_child_optional("source_configuration"));

    vd::VolumeConfig vol_config;

    if (maybe_source_pt)
    {
        const std::string source_ns((*maybe_source_pt).get<std::string>("namespace"));

        be::BackendConnectionManagerPtr
            source_cm(be::BackendConnectionManager::create(*maybe_source_pt,
                                                           RegisterComponent::F));

        be::BackendInterfacePtr source_bi(source_cm->newBackendInterface(backend::Namespace(source_ns)));
        copy_(source_bi->clone(), target_bi->clone());

        LOG_INFO("Retrieving volume config from source namespace " <<
                 source_bi->getNS());
        source_bi->fillObject(vol_config, InsistOnLatestVersion::T);
        vol_config.changeNamespace(backend::Namespace(target_nspace));
    }
    else
    {
        LOG_INFO("Retrieving volume config from target namespace " <<
                 target_bi->getNS());
        target_bi->fillObject(vol_config, InsistOnLatestVersion::T);
    }

    const boost::optional<std::string>
        maybe_new_name(target_pt.get_optional<std::string>("volume_name"));

    if (maybe_new_name)
    {
        LOG_INFO(target_nspace << ": renaming " << vol_config.id_ << " -> " <<
                 *maybe_new_name);
        const_cast<vd::VolumeId&>(vol_config.id_) = vd::VolumeId(*maybe_new_name);
    }

    const boost::optional<vd::VolumeConfig::WanBackupVolumeRole>
        maybe_new_role(target_pt.get_optional<vd::VolumeConfig::WanBackupVolumeRole>("volume_role"));

    if (maybe_new_role)
    {
        promote_(*maybe_new_role, target_bi->clone(), vol_config);
    }

    target_bi->writeObject(vol_config,
                           vd::VolumeConfig::config_backend_name,
                           OverwriteObject::T);
}
Esempio n. 20
0
int main(int argc, char **argv) {
    if (argc < 3) {
        fprintf(stderr, "Please enter a time quantums . . . . \n");
        exit(1);
    }
    time_slice = atoi(argv[1]);
    time_slice_1 = atoi(argv[2]);
    if (time_slice <= 0 || time_slice_1 <= 0) {
        fprintf(stderr, "Error! program usage rr < positive time quantum> < data file . . .\n");
        exit(1);
    }
    init_();
    clock_t ticks;
    time_t start_time, end_time;
    time(&start_time);
    int i;
    int status = 0;
    log_file = fopen("log_file.txt", "w+");
    if (log_file == NULL) {
        fprintf(stderr, "LOG FILE CANNOT BE OPEN\n");
    }
    //initialize cpu's
    for (i = 0; i < NUMBER_OF_PROCESSORS; i++) {
        CPU[i] = NULL;
    }
    initializeProcessQueue(&readyQueue);
    initializeProcessQueue(&waitingQueue);
    initializeProcessQueue(&level_one);
    initializeProcessQueue(&second_level);
    //initializeProcessQueue(&promoted);
    // read in process and initialize process values
    while ((status = (readProcess(&processes[number_of_processes])))) {
        if (status == 1) {
            number_of_processes++;
        }
    }
    if (number_of_processes > MAX_PROCESSES) {
        return -2;
    }
    if (number_of_processes == 0) {
        return -1;
    }
    int remaining_process = 0;
    //sort process by their arrival times
    qsort(processes, number_of_processes, sizeof (process), compareByArrival);
    // main execution loop
    while (TRUE) {
        ticks = clock();
        waiting_to_ready();
        incoming_process_init();
        running_process_to_waiting();
        most_ready_running_in_cpu();

        refresh_processes();
        increase_io_work();
        increase_cpu_work();

        cpu_utilized_time += runningProcesses();
        remaining_process = ex();
        // break when there are no more running or incoming processes, and the waiting queue is empty
        if (remaining_process == 0 && runningProcesses() == 0 && waitingQueue.size == 0) {
            break;
        }
        simulation_time++;
    }
    int total_waiting_time = 0;
    int turn_around_time = 0;
    for (i = 0; i < number_of_processes; i++) {
        turn_around_time += processes[i].endTime - processes[i].arrivalTime;
        total_waiting_time += processes[i].waitingTime;
    }
    printf(">>>>>>>>>>>>> FBQ with Q1 :%d\tQ2 :%d  <<<<<<<<<<<<<<<\n", time_slice, time_slice_1);
    printf("********************************************************************\n");
    printf("Average Waiting Time\t\t\t:%.2f\n", total_waiting_time / (double) number_of_processes);
    printf("Average Turn Around Time\t\t:%.2f\n", turn_around_time / (double) number_of_processes);
    printf("Time all for all CPU processes\t\t:%d\n", simulation_time);
    printf("CPU Utilization Time\t\t\t:%.2f%c\n", (double) (cpu_utilized_time * 100.0) / (double) (simulation_time), (int) 37);
    printf("Total Number of Context Switches\t:%d\n", context_switches);
    printf("Last Process to finish ");
    for (i = 0; i < number_of_processes; i++) {
        if (processes[i].endTime == simulation_time) {
            printf("PID\t\t:%d\n", processes[i].pid);
        }
    }
    printf("********************************************************************\n");
    time(&end_time);
    double prg_time = (end_time - start_time) * 0.001;
    double cpu_time = (double) ticks / CLOCKS_PER_SEC;
    fprintf(log_file, "Program Time\t:%.2fsecs\n", prg_time);
    fprintf(log_file, "CPU Time\t:%.2fsecs\n", cpu_time);
    fclose(log_file);
    return 0;
}
Esempio n. 21
0
void librandom::BinomialRandomDev::set_p(double p_s)
{
  p_ = p_s;
  init_();
}
	dstu4145_random_t::dstu4145_random_t()
		: m_ctx(0)
	{
		init_(0,0);
	}
Esempio n. 23
0
void BatchLogger::init(double timestep)
{
  init_(timestep);
}
Esempio n. 24
0
TiledLevelArray::TiledLevelArray(unsigned long w, unsigned long h) {
	_w=w;
	_h=h;

	init_();
}
Esempio n. 25
0
TriangleWrapper::TriangleWrapper( const Mesh & inMesh, Mesh & outMesh, const std::string & triSwitches )
    : inMesh_( & inMesh ) {
    init_();
    switches_ = triSwitches;
    generate( outMesh );
}
Esempio n. 26
0
plotter::plotter()
{
  init_();
}
Esempio n. 27
0
int main(int argc, char *argv[])
{
  init_();    
  srand(time(NULL));

  N = atoi(argv[1]);

  x = (double*)malloc(sizeof(double)*N);
  x_1 = (double*)malloc(sizeof(double)*N);
  y = (double*)malloc(sizeof(double)*N);
  y_1 = (double*)malloc(sizeof(double)*N);
  t_x = (double*)malloc(sizeof(double)*N);
  t_y = (double*)malloc(sizeof(double)*N);
  param = (double*)malloc(sizeof(double)*5);

  int i;
  for (i = 0; i < N; i++)
  {
    t_x[i] = rand()/1.0/RAND_MAX - 0.5;
    t_y[i] = rand()/1.0/RAND_MAX - 0.5;
  }
  for (i = 1; i < 5; i++)
  {
    param[i] = rand()/1.0/RAND_MAX - 0.5;
  }

  incx = 1;
  incy = 1;
  param[0] = -1.0;
  run_test();

  incx = 1;
  incy = 1;
  param[0] = 0.0;
  run_test();

  incx = 1;
  incy = 1;
  param[0] = 1.0;
  run_test();

  incx = 1;
  incy = 1;
  param[0] = -2.0;
  run_test();

  incx = -2;
  x = (double*)malloc(sizeof(double)*2*N);
  x_1 = (double*)malloc(sizeof(double)*2*N);
  incy = -1;
  param[0] = -1.0;
  run_test();

  incx = -2;
  x = (double*)malloc(sizeof(double)*2*N);
  x_1 = (double*)malloc(sizeof(double)*2*N);
  incy = -1;
  param[0] = 0.0;
  run_test();

  incx = -2;
  x = (double*)malloc(sizeof(double)*2*N);
  x_1 = (double*)malloc(sizeof(double)*2*N);
  incy = -1;
  param[0] = 1.0;
  run_test();

  incx = -2;
  x = (double*)malloc(sizeof(double)*2*N);
  x_1 = (double*)malloc(sizeof(double)*2*N);
  incy = -1;
  param[0] = -2.0;
  run_test();
  return 0;
}
Esempio n. 28
0
 explicit CorrelatedData() : gen_() { init_(); }
Esempio n. 29
0
			deflate_writer_imp(io::write_map& dest_, zip_format format, int level_, dict_type dict_, heap* h, int strategy_)
				: map_dest(&dest_)
			{
				init_(format, level_, dict_, h, strategy_);
			}