void rt2x00mac_erp_ie_changed(struct ieee80211_hw *hw, u8 changes, int cts_protection, int preamble) { struct rt2x00_dev *rt2x00dev = hw->priv; int short_preamble; int ack_timeout; int ack_consume_time; int difs; /* * We only support changing preamble mode. */ if (!(changes & IEEE80211_ERP_CHANGE_PREAMBLE)) return; short_preamble = !preamble; preamble = !!(preamble) ? PREAMBLE : SHORT_PREAMBLE; difs = (hw->conf.flags & IEEE80211_CONF_SHORT_SLOT_TIME) ? SHORT_DIFS : DIFS; ack_timeout = difs + PLCP + preamble + get_duration(ACK_SIZE, 10); ack_consume_time = SIFS + PLCP + preamble + get_duration(ACK_SIZE, 10); if (short_preamble) __set_bit(CONFIG_SHORT_PREAMBLE, &rt2x00dev->flags); else __clear_bit(CONFIG_SHORT_PREAMBLE, &rt2x00dev->flags); rt2x00dev->ops->lib->config_preamble(rt2x00dev, short_preamble, ack_timeout, ack_consume_time); }
static dword get_normal_duration(const TilemUserTimer* tmr) { if (tmr->loopvalue) return get_duration(tmr->frequency, tmr->loopvalue); else return get_duration(tmr->frequency, 256); }
static void rt2x00_dev_update_rate(struct _rt2x00_pci *rt2x00pci, struct _rt2x00_config *config) { u32 value = 0x00000000; u32 reg = 0x00000000; u8 counter = 0x00; DEBUG("Start.\n"); rt2x00_register_read(rt2x00pci, TXCSR1, ®); value = config->sifs + (2 * config->slot_time) + config->plcp + get_preamble(config) + get_duration(ACK_SIZE, capabilities.bitrate[0]); rt2x00_set_field32(®, TXCSR1_ACK_TIMEOUT, value); value = config->sifs + config->plcp + get_preamble(config) + get_duration(ACK_SIZE, capabilities.bitrate[0]); rt2x00_set_field32(®, TXCSR1_ACK_CONSUME_TIME, value); rt2x00_set_field32(®, TXCSR1_TSF_OFFSET, 0x18); rt2x00_set_field32(®, TXCSR1_AUTORESPONDER, 1); rt2x00_register_write(rt2x00pci, TXCSR1, reg); reg = 0x00000000; for(counter = 0; counter < 12; counter++){ reg |= cpu_to_le32(0x00000001 << counter); if(capabilities.bitrate[counter] == config->bitrate) break; } rt2x00_register_write(rt2x00pci, ARCSR1, reg); }
void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev, struct rt2x00_intf *intf, struct ieee80211_bss_conf *bss_conf) { struct rt2x00lib_erp erp; memset(&erp, 0, sizeof(erp)); erp.short_preamble = bss_conf->use_short_preamble; erp.ack_timeout = PLCP + get_duration(ACK_SIZE, 10); erp.ack_consume_time = SIFS + PLCP + get_duration(ACK_SIZE, 10); if (rt2x00dev->hw->conf.flags & IEEE80211_CONF_SHORT_SLOT_TIME) erp.ack_timeout += SHORT_DIFS; else erp.ack_timeout += DIFS; if (bss_conf->use_short_preamble) { erp.ack_timeout += SHORT_PREAMBLE; erp.ack_consume_time += SHORT_PREAMBLE; } else { erp.ack_timeout += PREAMBLE; erp.ack_consume_time += PREAMBLE; } rt2x00dev->ops->lib->config_erp(rt2x00dev, &erp); }
iter_type get_duration(iter_type i, iter_type e, std::ios_base& is, std::ios_base::iostate& err, duration<Rep, Period>& d) const { if (std::has_facet<duration_get<CharT> >(is.getloc())) { duration_get<CharT> const &facet = std::use_facet<duration_get<CharT> >(is.getloc()); return get_duration(facet, i, e, is, err, d); } else { duration_get<CharT> facet; return get_duration(facet, i, e, is, err, d); } }
double get_mem_speed(char *membuf, unsigned long npages) { const long weight = 1; struct timeval tv_sta; struct timeval tv_end; gettimeofday_or_error(&tv_sta); for (int repeated = 0; repeated < weight; repeated++) { for (unsigned long i = 0; i < npages; i++) { do_a_mem_task(membuf, i); } } gettimeofday_or_error(&tv_end); double duration = get_duration(&tv_sta, &tv_end); if (duration < 0.005) fprintf(stderr, "get_mem_speed: warning, duration %f is too small. increase weight\n", duration); if (duration > 0.1) fprintf(stderr, "get_mem_speed: warning, duration %f is too big. decrease weight\n", duration); double ret = 1.0L * npages / duration; // printf("duration %Lf, %f npages/s\n", duration, ret); return ret; }
static void rt2400pci_config_intf(struct rt2x00_dev *rt2x00dev, struct rt2x00_intf *intf, struct rt2x00intf_conf *conf, const unsigned int flags) { unsigned int bcn_preload; u32 reg; if (flags & CONFIG_UPDATE_TYPE) { /* * Enable beacon config */ bcn_preload = PREAMBLE + get_duration(IEEE80211_HEADER, 20); rt2x00pci_register_read(rt2x00dev, BCNCSR1, ®); rt2x00_set_field32(®, BCNCSR1_PRELOAD, bcn_preload); rt2x00pci_register_write(rt2x00dev, BCNCSR1, reg); /* * Enable synchronisation. */ rt2x00pci_register_read(rt2x00dev, CSR14, ®); rt2x00_set_field32(®, CSR14_TSF_COUNT, 1); rt2x00_set_field32(®, CSR14_TSF_SYNC, conf->sync); rt2x00_set_field32(®, CSR14_TBCN, 1); rt2x00pci_register_write(rt2x00dev, CSR14, reg); } if (flags & CONFIG_UPDATE_MAC) rt2x00pci_register_multiwrite(rt2x00dev, CSR3, conf->mac, sizeof(conf->mac)); if (flags & CONFIG_UPDATE_BSSID) rt2x00pci_register_multiwrite(rt2x00dev, CSR5, conf->bssid, sizeof(conf->bssid)); }
void StringHost::lua(lua_State* vm, bool returnHost) { lua_newtable(vm); lua_push_str_table_entry(vm, "name", keyname); lua_push_int_table_entry(vm, "bytes.sent", sent.getNumBytes()); lua_push_int_table_entry(vm, "bytes.rcvd", rcvd.getNumBytes()); lua_push_int_table_entry(vm, "pkts.sent", sent.getNumPkts()); lua_push_int_table_entry(vm, "pkts.rcvd", rcvd.getNumPkts()); lua_push_int_table_entry(vm, "queries.rcvd", queriesReceived); lua_push_int_table_entry(vm, "seen.first", first_seen); lua_push_int_table_entry(vm, "seen.last", last_seen); lua_push_int_table_entry(vm, "duration", get_duration()); lua_push_int_table_entry(vm, "family", family_id); lua_push_float_table_entry(vm, "throughput", bytes_thpt); lua_push_int_table_entry(vm, "throughput_trend", getThptTrend()); if(ndpiStats) ndpiStats->lua(iface, vm); getHostContacts(vm); if(returnHost) { lua_pushstring(vm, keyname); lua_insert(vm, -2); lua_settable(vm, -3); } }
static void rt2400pci_config_type(struct rt2x00_dev *rt2x00dev, const int type, const int tsf_sync) { u32 reg; rt2x00pci_register_write(rt2x00dev, CSR14, 0); /* * Enable beacon config */ rt2x00pci_register_read(rt2x00dev, BCNCSR1, ®); rt2x00_set_field32(®, BCNCSR1_PRELOAD, PREAMBLE + get_duration(IEEE80211_HEADER, 20)); rt2x00pci_register_write(rt2x00dev, BCNCSR1, reg); /* * Enable synchronisation. */ rt2x00pci_register_read(rt2x00dev, CSR14, ®); rt2x00_set_field32(®, CSR14_TSF_COUNT, 1); rt2x00_set_field32(®, CSR14_TBCN, 1); rt2x00_set_field32(®, CSR14_BEACON_GEN, 0); rt2x00_set_field32(®, CSR14_TSF_SYNC, tsf_sync); rt2x00pci_register_write(rt2x00dev, CSR14, reg); }
/* FIXME! We should do the array thing here too. */ static void parse_sample_keyvalue(void *_sample, const char *key, const char *value) { struct sample *sample = _sample; if (!strcmp(key, "sensor")) { sample->sensor = atoi(value); return; } if (!strcmp(key, "ndl")) { sample->ndl = get_duration(value); return; } if (!strcmp(key, "tts")) { sample->tts = get_duration(value); return; } if (!strcmp(key, "in_deco")) { sample->in_deco = atoi(value); return; } if (!strcmp(key, "stoptime")) { sample->stoptime = get_duration(value); return; } if (!strcmp(key, "stopdepth")) { sample->stopdepth = get_depth(value); return; } if (!strcmp(key, "cns")) { sample->cns = atoi(value); return; } if (!strcmp(key, "po2")) { pressure_t p = get_pressure(value); sample->setpoint.mbar = p.mbar; return; } if (!strcmp(key, "heartbeat")) { sample->heartbeat = atoi(value); return; } if (!strcmp(key, "bearing")) { sample->bearing.degrees = atoi(value); return; } report_error("Unexpected sample key/value pair (%s/%s)", key, value); }
int main_loop() { if( arm_main_timers() == -1) { wrn_print("failed to arm ring timers"); terminate(); } if(arm_24h_sig() == -1) { wrn_print("failed to arm 24h \"killer timer\""); terminate(); } sigset_t set; if(sigfillset(&set) == -1 ) { err_print ("sigwaitinfo"); return -1; } siginfo_t info; char *custom_dur; for( ;; ) { int sig = sigwaitinfo(&set, &info); dbg_print("FETCHED %s SIGNAL(%ld)",strsignal(sig),(long)sig); if(IS_EXIT_SIG(sig)) { dbg_print("%s SIGNAL(%ld) - exit sig; exiting", strsignal(sig),(long)sig); exit(EXIT_SUCCESS); } if(sig == SIG_RING_CUSTOM) { custom_dur = get_duration(&info); ring(custom_dur); continue; } switch(sig) { case -1: if(errno != EAGAIN) { err_print("sigwaitinfo"); break; } case SIG_REXEC: rexec(); break; case SIG_RING_SHORT: ring(cmd.short_ring); break; case SIG_RING_LONG: ring(cmd.long_ring); break; case SIGCHLD: zombie_assasin(); break; } } }
void timestamp_calculator_c::set_samples_per_second(int64_t samples_per_second) { if (!samples_per_second || (samples_per_second == m_samples_per_second)) return; m_reference_timecode += get_duration(m_samples_since_reference_timecode); m_samples_since_reference_timecode = 0; m_samples_to_timestamp.set(1000000000, samples_per_second); }
void report_speed() { char tx_bitrate_string[80], rx_bitrate_string[80]; time_in_us d = get_duration(); make_bitrate_string(tx_bitrate_string, calculate_tx_bitrate(d)); make_bitrate_string(rx_bitrate_string, calculate_rx_bitrate(d)); fprintf(stdout, "tx_bitrate [%s] | rx_bitrate [%s]\n", tx_bitrate_string, rx_bitrate_string); }
void Flow::print_peers(lua_State* vm, bool verbose) { char buf1[64], buf2[64], buf[256]; Host *src = get_cli_host(), *dst = get_srv_host(); if((src == NULL) || (dst == NULL)) return; lua_newtable(vm); lua_push_str_table_entry(vm, "client", get_cli_host()->get_ip()->print(buf, sizeof(buf))); lua_push_str_table_entry(vm, "server", get_srv_host()->get_ip()->print(buf, sizeof(buf))); lua_push_int_table_entry(vm, "sent", cli2srv_bytes); lua_push_int_table_entry(vm, "rcvd", srv2cli_bytes); lua_push_int_table_entry(vm, "sent.last", get_current_bytes_cli2srv()); lua_push_int_table_entry(vm, "rcvd.last", get_current_bytes_srv2cli()); lua_push_int_table_entry(vm, "duration", get_duration()); lua_push_float_table_entry(vm, "client.latitude", get_cli_host()->get_latitude()); lua_push_float_table_entry(vm, "client.longitude", get_cli_host()->get_longitude()); lua_push_float_table_entry(vm, "server.latitude", get_srv_host()->get_latitude()); lua_push_float_table_entry(vm, "server.longitude", get_srv_host()->get_longitude()); if(verbose) { lua_push_bool_table_entry(vm, "client.private", get_cli_host()->get_ip()->isPrivateAddress()); lua_push_str_table_entry(vm, "client.country", get_cli_host()->get_country() ? get_cli_host()->get_country() : (char*)""); lua_push_bool_table_entry(vm, "server.private", get_srv_host()->get_ip()->isPrivateAddress()); lua_push_str_table_entry(vm, "server.country", get_srv_host()->get_country() ? get_srv_host()->get_country() : (char*)""); lua_push_str_table_entry(vm, "client.city", get_cli_host()->get_city() ? get_cli_host()->get_city() : (char*)""); lua_push_str_table_entry(vm, "server.city", get_srv_host()->get_city() ? get_srv_host()->get_city() : (char*)""); if(verbose) { if(((cli2srv_packets+srv2cli_packets) > NDPI_MIN_NUM_PACKETS) || (ndpi_detected_protocol != NDPI_PROTOCOL_UNKNOWN) || iface->is_ndpi_enabled() || iface->is_sprobe_interface()) lua_push_str_table_entry(vm, "proto.ndpi", get_detected_protocol_name()); else lua_push_str_table_entry(vm, "proto.ndpi", (char*)CONST_TOO_EARLY); } } // Key /* Too slow */ #if 0 snprintf(buf, sizeof(buf), "%s %s", src->Host::get_name(buf1, sizeof(buf1), false), dst->Host::get_name(buf2, sizeof(buf2), false)); #else snprintf(buf, sizeof(buf), "%s %s", intoaV4(ntohl(get_cli_ipv4()), buf1, sizeof(buf1)), intoaV4(ntohl(get_srv_ipv4()), buf2, sizeof(buf2))); #endif lua_pushstring(vm, buf); lua_insert(vm, -2); lua_settable(vm, -3); }
static void rt2400pci_config_erp(struct rt2x00_dev *rt2x00dev, struct rt2x00lib_erp *erp) { int preamble_mask; u32 reg; /* * When short preamble is enabled, we should set bit 0x08 */ preamble_mask = erp->short_preamble << 3; rt2x00pci_register_read(rt2x00dev, TXCSR1, ®); rt2x00_set_field32(®, TXCSR1_ACK_TIMEOUT, erp->ack_timeout); rt2x00_set_field32(®, TXCSR1_ACK_CONSUME_TIME, erp->ack_consume_time); rt2x00pci_register_write(rt2x00dev, TXCSR1, reg); rt2x00pci_register_read(rt2x00dev, ARCSR2, ®); rt2x00_set_field32(®, ARCSR2_SIGNAL, 0x00); rt2x00_set_field32(®, ARCSR2_SERVICE, 0x04); rt2x00_set_field32(®, ARCSR2_LENGTH, get_duration(ACK_SIZE, 10)); rt2x00pci_register_write(rt2x00dev, ARCSR2, reg); rt2x00pci_register_read(rt2x00dev, ARCSR3, ®); rt2x00_set_field32(®, ARCSR3_SIGNAL, 0x01 | preamble_mask); rt2x00_set_field32(®, ARCSR3_SERVICE, 0x04); rt2x00_set_field32(®, ARCSR2_LENGTH, get_duration(ACK_SIZE, 20)); rt2x00pci_register_write(rt2x00dev, ARCSR3, reg); rt2x00pci_register_read(rt2x00dev, ARCSR4, ®); rt2x00_set_field32(®, ARCSR4_SIGNAL, 0x02 | preamble_mask); rt2x00_set_field32(®, ARCSR4_SERVICE, 0x04); rt2x00_set_field32(®, ARCSR2_LENGTH, get_duration(ACK_SIZE, 55)); rt2x00pci_register_write(rt2x00dev, ARCSR4, reg); rt2x00pci_register_read(rt2x00dev, ARCSR5, ®); rt2x00_set_field32(®, ARCSR5_SIGNAL, 0x03 | preamble_mask); rt2x00_set_field32(®, ARCSR5_SERVICE, 0x84); rt2x00_set_field32(®, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110)); rt2x00pci_register_write(rt2x00dev, ARCSR5, reg); }
int track_segment::get_duration_str(char *s, size_t n) const { double t = get_duration(); int hours, minutes, seconds; hours = static_cast<int>(t / 3600); t -= hours * 3600; minutes = static_cast<int>(t / 60); t -= minutes * 60; seconds = static_cast<int>(t); return std::snprintf(s, n, "%1d:%02d:%02d", hours, minutes, seconds); }
/* To print the solution in gantt chart like format */ void print_graph(solution_t *soln) { job_t *jobs = soln->jobs; int *jobs_order = soln->jobs_order; int i, j, job_id; int current_pos; for(i=0; i<numnodes+1; i++) { current_pos = 0; job_id = jobs_order[i]; printf("Job ID %d:\t", job_id); /* Print the release date */ for(j=0; j<(int) node_tw[job_id][0]; j++) { current_pos++; printf(" "); } printf("["); /* Print the underscore ( _ ) to represent the time before the start of the job */ for(j=current_pos; j<(int)(get_start_time(job_id, soln)); j++) { current_pos++; if(current_pos == (int) node_tw[job_id][1]) printf("*"); else if(current_pos > (int) node_tw[job_id][0]) printf("_"); } /* Print the duration of the job */ for(j=0; j<(int)(get_duration(job_id, soln)); j++) { current_pos++; if(current_pos == (int) node_tw[job_id][1]) printf("*"); else printf("|"); } /* Print the due date if it is not yet passed */ if(current_pos < (int) node_tw[job_id][1]) { for(j=current_pos; j < (int)node_tw[job_id][1]; j++) printf("_"); printf("]"); } printf("\n"); } print_legend(); }
static int microdvd_read_header(AVFormatContext *s) { AVRational pts_info = (AVRational){ 2997, 125 }; /* default: 23.976 fps */ MicroDVDContext *microdvd = s->priv_data; AVStream *st = avformat_new_stream(s, NULL); int i = 0; char line[MAX_LINESIZE]; if (!st) return AVERROR(ENOMEM); while (!url_feof(s->pb)) { AVPacket *sub; int64_t pos = avio_tell(s->pb); int len = ff_get_line(s->pb, line, sizeof(line)); if (!len) break; if (i < 3) { int frame; double fps; char c; i++; if ((sscanf(line, "{%d}{}%6lf", &frame, &fps) == 2 || sscanf(line, "{%d}{%*d}%6lf", &frame, &fps) == 2) && frame <= 1 && fps > 3 && fps < 100) pts_info = av_d2q(fps, 100000); if (!st->codec->extradata && sscanf(line, "{DEFAULT}{}%c", &c) == 1) { st->codec->extradata = av_strdup(line + 11); if (!st->codec->extradata) return AVERROR(ENOMEM); st->codec->extradata_size = strlen(st->codec->extradata) + 1; continue; } } sub = ff_subtitles_queue_insert(µdvd->q, line, len, 0); if (!sub) return AVERROR(ENOMEM); sub->pos = pos; sub->pts = get_pts(sub->data); sub->duration = get_duration(sub->data); } ff_subtitles_queue_finalize(µdvd->q); avpriv_set_pts_info(st, 64, pts_info.den, pts_info.num); st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE; st->codec->codec_id = AV_CODEC_ID_MICRODVD; return 0; }
static PyObject * python_get_duration(PyObject *self, PyObject *args ) { char *usage = "Usage: _seisparams._get_duration( magnitude, dept, distance, vp, vs, soil_type )"; PyObject *obj; double retval, magnitude, depth, distance, vp, vs, soil_type; if( ! PyArg_ParseTuple( args, "dddddd", &magnitude, &depth, &distance, &vp, &vs, &soil_type ) ) { USAGE; return NULL; } retval=get_duration( magnitude, depth, distance, vp, vs, soil_type); obj = Py_BuildValue( "d", retval ); return obj; }
void Controller::schedule_model_update() { try { RealTime time = model_.get_next_event_time(); std::thread([time, this]() { auto time_difference = time - RealTime::now(); LOG(time_difference); std::this_thread::sleep_for(time_difference.get_duration()); event_queue_.push(new UpdateModelEvent(time)); }).detach(); } catch(InfiniteRealTime) { } }
static UINT64 get_amp_filesize_limit(const CONF_GUIEX *conf, const OUTPUT_INFO *oip, PRM_ENC *pe, const SYSTEM_DATA *sys_dat) { UINT64 filesize_limit = MAXUINT64; if (conf->x264.use_auto_npass) { //上限ファイルサイズのチェック if (conf->vid.amp_check & AMPLIMIT_FILE_SIZE) { filesize_limit = min(filesize_limit, (UINT64)(conf->vid.amp_limit_file_size*1024*1024)); } //上限ビットレートのチェック if (conf->vid.amp_check & AMPLIMIT_BITRATE_UPPER) { const double duration = get_duration(conf, sys_dat, pe, oip); filesize_limit = min(filesize_limit, (UINT64)(conf->vid.amp_limit_bitrate_upper * 1000 / 8 * duration)); } } //音声のサイズはここでは考慮しない //音声のサイズも考慮してしまうと、のちの判定で面倒なことになる //(muxをしないファイルを評価してしまい、上限をクリアしていると判定されてしまう) return (MAXUINT64 == filesize_limit) ? 0 : filesize_limit; }
/** Send value table packet to controller via serial port (layer 3). * * \param reason The reason why we are sending the value table * (#packet_value_table_reason_t). * * Note that send_table() might take a significant amount of time. * For example, at 9600bps, transmitting a good 3KByte will take a * good 3 seconds. If you disable interrupts for that time and want * to continue the measurement later, you will want to properly pause * the timer. We are currently keeping interrupts enabled if we * continue measuring, which avoids this issue. * * Note that for 'I' value tables it is possible that we send fluked * values due to overflows. */ void send_table(const packet_value_table_reason_t reason) { const uint16_t duration = get_duration(); packet_value_table_header_t header = { data_table_info.bits_per_value, reason, data_table_info.type, duration, pparam_sram.length }; frame_start(FRAME_TYPE_VALUE_TABLE, sizeof(header) + pparam_sram.length + data_table_info.size); uart_putb((const void *)&header, sizeof(header)); uart_putb((const void *)pparam_sram.params, pparam_sram.length); uart_putb((const void *)data_table, data_table_info.size); frame_end(); }
/* To print the details of the solution */ void print_solution(solution_t *soln) { job_t *jobs = soln->jobs; int *jobs_order = soln->jobs_order; int i, job_id; float duration; for(i=0; i<numnodes+1; i++) { job_id = jobs_order[i]; duration = jobs[job_id].end_time - jobs[job_id].start_time; printf("-----------------\n"); printf("Job #: %d\n", job_id); printf("Job order: %d\n", get_job_order(job_id, soln)); if(i > 0) printf("Waiting time: %f\n", get_waiting_time(jobs_order[i-1], job_id, soln)); printf("Start Time: %f\n", get_start_time(job_id, soln)); printf("End Time: %f\n", get_end_time(job_id, soln)); printf("Duration: %f\n", get_duration(job_id, soln)); printf("Lateness: %f\n", get_lateness_time(job_id, soln)); printf("-----------------\n"); } }
void dump(const mcmc ** chains, const unsigned int n_beta, const unsigned long iter, FILE * acceptance_file, FILE ** probabilities_file) { unsigned int i; if (iter % PRINT_PROB_INTERVAL == 0) { if (dumpflag) { report(chains, n_beta); dumpflag = 0; for (i = 0; i < n_beta; i++) { fflush(probabilities_file[i]); } } fprintf(acceptance_file, "%lu", iter); for (i = 0; i < n_beta; i++) { fprintf(acceptance_file, "\t%lu", get_params_accepts_global( chains[i])); } fprintf(acceptance_file, "\n"); fflush(acceptance_file); IFDEBUG { debug("dumping distribution"); dump_ul("iteration", iter); dump_ul("acceptance rate: accepts", get_params_accepts_global(chains[0])); dump_ul("acceptance rate: rejects", get_params_rejects_global(chains[0])); dump_mcmc(chains[0]); } else { printf("iteration: %lu, a/r: %.3f(%lu/%lu), v:", iter, (double) get_params_accepts_global(chains[0]) / (double) (get_params_accepts_global(chains[0]) + get_params_rejects_global(chains[0])), get_params_accepts_global(chains[0]), get_params_rejects_global(chains[0])); dump_vector(get_params(chains[0])); printf(" [%d/%lu ticks]\r", get_duration(), get_ticks_per_second()); fflush(stdout); } }
double get_cpu_speed(void) { // const long nloops = 100000 * 10; const long weight = 10; const long nloops = 1000 * weight; struct timeval tv_sta; struct timeval tv_end; gettimeofday_or_error(&tv_sta); for (long i = 0; i < nloops; i++) { do_a_cpu_task(); } gettimeofday_or_error(&tv_end); double duration = get_duration(&tv_sta, &tv_end); if (duration < 0.005) fprintf(stderr, "get_cpu_speed: warning, duration %f is too small. increase weight\n", duration); if (duration > 0.1) fprintf(stderr, "get_cpu_speed: warning, duration %f is too big. decrease weight\n", duration); double ret = 1.0L * nloops / duration; // printf("%f loops/s\n", ret); // if (ret > 100000000) { fprintf(stderr, "%f \n", duration); } return ret; }
static void rt2x00_dev_update_duration(struct _rt2x00_pci *rt2x00pci, struct _rt2x00_config *config) { u32 reg = 0x00000000; DEBUG("Start.\n"); rt2x00_register_read(rt2x00pci, CSR11, ®); rt2x00_set_field32(®, CSR11_CWMIN, 5); /* 2^5 = 32. */ rt2x00_set_field32(®, CSR11_CWMAX, 10); /* 2^10 = 1024. */ rt2x00_set_field32(®, CSR11_SLOT_TIME, config->slot_time); rt2x00_set_field32(®, CSR11_CW_SELECT, 1); rt2x00_register_write(rt2x00pci, CSR11, reg); rt2x00_register_read(rt2x00pci, CSR18, ®); rt2x00_set_field32(®, CSR18_SIFS, config->sifs); rt2x00_set_field32(®, CSR18_PIFS, config->sifs + config->slot_time); rt2x00_register_write(rt2x00pci, CSR18, reg); rt2x00_register_read(rt2x00pci, CSR19, ®); rt2x00_set_field32(®, CSR19_DIFS, config->sifs + (2 * config->slot_time)); rt2x00_set_field32(®, CSR19_EIFS, config->sifs + get_duration((IEEE80211_HEADER + ACK_SIZE), capabilities.bitrate[0])); rt2x00_register_write(rt2x00pci, CSR19, reg); }
static void print_last_report_record (GList *list, CkLogEvent *event, gboolean legacy_compat) { GString *str; char *username; char *utline; char *host; char *addedtime; char *removedtime; char *duration; char *session_type; char *session_id; char *seat_id; CkLogSeatSessionAddedEvent *e = NULL; CkLogEvent *remove_event; RecordStatus status; time_t added_t, removed_t; if (event->type != CK_LOG_EVENT_SEAT_SESSION_ADDED && event->type != CK_LOG_EVENT_SYSTEM_START) { return; } remove_event = NULL; if (event->type == CK_LOG_EVENT_SEAT_SESSION_ADDED) { e = (CkLogSeatSessionAddedEvent *)event; remove_event = find_first_matching_remove_event (list->next, e); status = get_event_record_status (remove_event); session_type = e->session_type; session_id = e->session_id; seat_id = e->seat_id; } else { status = RECORD_STATUS_REBOOT; remove_event = find_first_matching_system_stop_event (list->next, NULL); session_type = ""; session_id = ""; seat_id = ""; } str = g_string_new (NULL); username = get_user_name_for_event (event); utline = get_utline_for_event (event); host = get_host_for_event (event); added_t = event->timestamp.tv_sec; addedtime = g_strndup (ctime (&added_t), 16); if (legacy_compat) { g_string_printf (str, "%-8.8s %-12.12s %-16.16s %-16.16s", username, utline != NULL ? utline : "", host != NULL ? host : "", addedtime); } else { g_string_printf (str, "%-"USERNAME_MAX"."USERNAME_MAX"s %12s %-10.10s %-7.7s %-12.12s %-28.28s %-16.16s", username, session_type, session_id, seat_id, utline, host != NULL ? host : "", addedtime); } g_free (username); g_free (addedtime); g_free (utline); g_free (host); removedtime = NULL; duration = NULL; switch (status) { case RECORD_STATUS_CRASH: duration = get_duration (event, remove_event); removedtime = g_strdup ("- crash"); break; case RECORD_STATUS_DOWN: duration = get_duration (event, remove_event); removedtime = g_strdup ("- down "); break; case RECORD_STATUS_NOW: duration = g_strdup ("logged in"); removedtime = g_strdup (" still"); break; case RECORD_STATUS_PHANTOM: duration = g_strdup ("- no logout"); removedtime = g_strdup (" gone"); break; case RECORD_STATUS_REBOOT: duration = get_duration (event, remove_event); removedtime = g_strdup (""); break; case RECORD_STATUS_TIMECHANGE: duration = g_strdup (""); removedtime = g_strdup (""); break; case RECORD_STATUS_NORMAL: duration = get_duration (event, remove_event); removed_t = remove_event->timestamp.tv_sec; removedtime = g_strdup_printf ("- %s", ctime (&removed_t) + 11); removedtime[7] = 0; break; default: g_assert_not_reached (); break; } g_string_append_printf (str, " %-7.7s %-12.12s", removedtime, duration); g_print ("%s\n", str->str); g_string_free (str, TRUE); g_free (removedtime); g_free (duration); }
constexpr operator subframes() const { return get_duration(); }
constexpr x_subframe_number get_modulo() const { return x_subframe_number(get_duration()); }
int main(int argc, char *argv[]){ int i; int written; int userfile; int qosfile; int char_pos; int endfile = 0; char *name; int option_index; int opt_char; while((opt_char = getopt_long(argc, argv, "cjpamt", long_options, &option_index)) != -1) { switch (opt_char) { case (int)'c': total_cpus = atoi(optarg); case (int)'j': total_jobs = atoi(optarg); break; case (int)'p': default_partition = strdup(optarg); break; case (int)'a': default_account = strdup(optarg); break; case (int)'m': cpus_per_task = atoi(optarg); break; case (int)'t': tasks_per_node = atoi(optarg); break; case (int)'s': submit_time = atoi(optarg); break; default: fprintf(stderr, "getopt error, returned %c\n", opt_char); exit(0); } } if(total_cpus == 0){ printf("Usage: %s --cpus=xx --jobs=xx --partition=xxxx --account=xxxx --cpus_per_task=xx --tasks_per_node=xx --submit_time=xx(unixtime)\n", argv[0]); return -1; } if(total_jobs == 0){ printf("Usage: %s --cpus=xx --jobs=xx --partition=xxxx --account=xxxx --cpus_per_task=xx --tasks_per_node=xx --submit_time=xx(unixtime)\n", argv[0]); return -1; } if(default_partition == NULL){ printf("Usage: %s --cpus=xx --jobs=xx --partition=xxxx --account=xxxx --cpus_per_task=xx --tasks_per_node=xx --submit_time=xx(unixtime)\n", argv[0]); return -1; } if(default_account == NULL){ printf("Usage: %s --cpus=xx --jobs=xx --partition=xxxx --account=xxxx --cpus_per_task=xx --tasks_per_node=xx --submit_time=xx(unixtime)\n", argv[0]); return -1; } if(cpus_per_task == 0){ printf("Usage: %s --cpus=xx --jobs=xx --partition=xxxx --account=xxxx --cpus_per_task=xx --tasks_per_node=xx --submit_time=xx(unixtime)\n", argv[0]); return -1; } if(tasks_per_node == 0){ printf("Usage: %s --cpus=xx --jobs=xx --partition=xxxx --account=xxxx --cpus_per_task=xx --tasks_per_node=xx --submit_time=xx(unixtime)\n", argv[0]); return -1; } if(submit_time == 0){ printf("Usage: %s --cpus=xx --jobs=xx --partition=xxxx --account=xxxx --cpus_per_task=xx --tasks_per_node=xx --submit_time=xx(unixtime)\n", argv[0]); return -1; } //PATKI: Replacing 40 with 16 //if(total_cpus < 40){ if(total_cpus < 16){ printf("Setting total_cpus to the minimum value: 16\n"); total_cpus = 16; } userfile = open("users.sim", O_RDONLY); if(userfile < 0){ printf("users.sim file not found\n"); return -1; } while(1){ char_pos = 0; name = malloc(30); while(1){ if(read(userfile, &name[char_pos], 1) <= 0){ endfile = 1; break; }; //printf("Reading char: %c\n", username[char_pos][total_users]); if(name[char_pos] == '\n'){ name[char_pos] = '\0'; break; } char_pos++; } if(endfile) break; username[total_users] = name; printf("Reading user: %s\n", username[total_users]); total_users++; } qosfile = open("qos.sim", O_RDONLY); if(qosfile < 0){ printf("qos.sim file not found\n"); return -1; } endfile = 0; while(1){ char_pos = 0; name = malloc(30); while(1){ if(read(qosfile, &name[char_pos], 1) <= 0){ endfile = 1; break; }; //printf("Reading char: %c\n", username[char_pos][total_users]); if(name[char_pos] == '\n'){ name[char_pos] = '\0'; break; } char_pos++; } if(endfile) break; qosname[total_qos] = name; printf("Reading qos: %s\n", qosname[total_qos]); total_qos++; } if((trace_file = open("test.trace", O_CREAT | O_RDWR, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0){ printf("Error opening file test.trace\n"); return -1; } submit_time = 1316242565; for(i = 0; i < total_jobs; i++){ int j; new_trace.job_id = job_counter++; /* Submitting a job every 30s */ new_trace.submit = submit_time; submit_time += 30; sprintf(new_trace.username, username[i % total_users]); sprintf(new_trace.qosname, qosname[i % total_qos]); /*PATKI: WHY CAN I HAVE A JOB WITH 0 TASKS and 0 SEC DURATION?? I AM FIXING THIS*/ do{ new_trace.duration = get_duration(); if(new_trace.duration < 0){ printf("frand did not work. Exiting...\n"); return -1; } }while(new_trace.duration==0); //Patki, add a do-while check do{ new_trace.tasks = get_tasks(); if(new_trace.tasks < 0){ printf("frand did not work. Exiting...\n"); return -1; } }while(new_trace.tasks == 0); new_trace.wclimit = new_trace.duration + (new_trace.duration *0.30); if(new_trace.wclimit < 60) new_trace.wclimit = 60; sprintf(new_trace.account, "%s", default_account); sprintf(new_trace.partition, "%s", default_partition); new_trace.cpus_per_task = 1; new_trace.tasks_per_node = 4; written = write(trace_file, &new_trace, sizeof(new_trace)); printf("JOB(%s): %d, %d, %d\n", new_trace.username, job_counter - 1, new_trace.duration, new_trace.tasks); if(written != sizeof(new_trace)){ printf("Error writing to file: %d of %ld\n", written, sizeof(new_trace)); return -1; } } return 0; }