void la_wait (t_nombre_semaforo identificador_semaforo){ if(status_check() != EXECUTING) return; void * buffer = NULL, *response_buffer = calloc(1,sizeof(char)); int buffer_index = 0, identificador_semaforo_length = (int) strlen(identificador_semaforo); char operation = SEMAPHORE_ID, action = WAIT_ID; // asprintf(&buffer, "%d%d%04d%s", atoi(SEMAPHORE_ID), atoi(WAIT_ID), strlen(identificador_semaforo), identificador_semaforo); serialize_data(&operation, sizeof(char), &buffer, &buffer_index); serialize_data(&action, sizeof(char), &buffer, &buffer_index); serialize_data(&identificador_semaforo_length, sizeof(int), &buffer, &buffer_index); serialize_data(identificador_semaforo, (size_t) identificador_semaforo_length, &buffer, &buffer_index); if(send(kernelSocketClient, buffer, (size_t) buffer_index, 0) < 0) { log_error(cpu_log, "wait(%s) failed", identificador_semaforo); return; } status_update(WAITING); log_info(cpu_log, "Starting wait"); //me quedo esperando activamente a que kernel me responda // recv(kernelSocketClient, response_buffer, sizeof(char), 0); //kernel_response debería ser '0' // log_info(cpu_log, "Finished wait"); free(buffer); free(response_buffer); }
void mc6843_device::device_reset() { int i; LOG (( "mc6843 reset\n" )); /* setup/reset floppy drive */ for ( i = 0; i < 4; i++ ) { legacy_floppy_image_device * img = floppy_image( i ); img->floppy_mon_w(CLEAR_LINE); img->floppy_drive_set_ready_state(FLOPPY_DRIVE_READY, 0 ); img->floppy_drive_set_rpm( 300. ); } /* reset registers */ m_CMR &= 0xf0; /* zero only command */ m_ISR = 0; m_STRA &= 0x5c; m_SAR = 0; m_STRB &= 0x20; status_update( ); m_data_size = 0; m_data_idx = 0; m_timer_cont->adjust( attotime::never ); }
static void force_update(void) { status_update(); time_t now = time(NULL); update_time(localtime(&now)); update_bounds(); }
void finished_quantum_post_process() { printf(ANSI_COLOR_RED); log_info(cpu_log, "=== Finished Quantum ==="); printf(ANSI_COLOR_RESET); if(status_check() == EXECUTING) { status_update(READY); } if(status_check() == BLOCKED || status_check() == WAITING) { return; } send_quantum_end_notif(); }
int execute_line(void *instruction_line) { if(strcmp(instruction_line, "end") == 0) { //End of program reached status_update(EXIT); return EXIT; } log_info(cpu_log, "Starting delay of : %d seconds", actual_kernel_data->QSleep/1000); usleep(actual_kernel_data->QSleep * 1000); analizadorLinea((char*) instruction_line, &funciones_generales_ansisop, &funciones_kernel_ansisop); log_info(cpu_log, "Finished line %d execution", actual_pcb->program_counter); return SUCCESS; }
/* Single / Multiple Sector Write bottom half */ void mc6843_device::cont_SW( ) { chrn_id id; /* sector seek */ if ( ! address_search( &id ) ) return; /* setup sector write buffer */ m_data_idx = 0; m_data_size = 128; m_STRA |= 0x01; /* set Data Transfer Request */ m_data_id = id.data_id; /* for subsequent write sector command */ status_update( ); }
/* called at end of command */ void mc6843_device::cmd_end( ) { int cmd = m_CMR & 0x0f; if ( ( cmd == CMD_STZ ) || ( cmd == CMD_SEK ) ) { m_ISR |= 0x02; /* set Settling Time Complete */ } else { m_ISR |= 0x01; /* set Macro Command Complete */ } m_STRA &= ~0x80; /* clear Busy */ m_CMR &= 0xf0; /* clear command */ status_update( ); }
/* Single / Multiple Sector Read bottom half */ void mc6843_device::cont_SR( ) { chrn_id id; legacy_floppy_image_device* img = floppy_image( ); /* sector seek */ if ( ! address_search_read( &id ) ) return; /* sector read */ img->floppy_drive_read_sector_data( m_side, id.data_id, m_data, 128 ); m_data_idx = 0; m_data_size = 128; m_STRA |= 0x01; /* set Data Transfer Request */ status_update( ); }
int get_pcb() { //Pido por kernel process data actual_kernel_data = calloc(1, sizeof(t_kernel_data)); log_info(cpu_log, "Waiting for kernel PCB and Quantum data"); if (recibir_pcb(kernelSocketClient, actual_kernel_data) <= 0) { log_error(cpu_log, "Error receiving PCB and Quantum data from KERNEL"); return ERROR; } //Deserializo el PCB que recibo actual_pcb = (t_pcb *) calloc(1,sizeof(t_pcb)); int last_buffer_index = 0; deserialize_pcb(&actual_pcb, actual_kernel_data->serialized_pcb, &last_buffer_index); //Inicializo si tengo que if (get_last_entry(actual_pcb->stack_index)== NULL) { actual_pcb->stack_index = queue_create(); t_stack_entry * first_empty_entry = calloc(1, sizeof(t_stack_entry)); queue_push(actual_pcb->stack_index, first_empty_entry); } status_update(EXECUTING); return SUCCESS; }
void entradaSalida(t_nombre_dispositivo dispositivo, int tiempo) { if(status_check() != EXECUTING) return; //cambio el estado del pcb status_update(BLOCKED); //3+ ioNameSize + ioName + io_units (1+4+ioNameSize+4 bytes) void * buffer = NULL; char operation = ENTRADA_SALIDA_ID; int dispositivo_length = (int) strlen(dispositivo), buffer_index = 0; //Armo paquete de I/O operation // asprintf(&buffer, "%d%04d%s%04d", atoi(ENTRADA_SALIDA_ID), strlen(dispositivo), dispositivo, tiempo); serialize_data(&operation, sizeof(char), &buffer, &buffer_index); serialize_data(&dispositivo_length, sizeof(int), &buffer, &buffer_index); serialize_data(dispositivo, (size_t) dispositivo_length, &buffer, &buffer_index); serialize_data(&tiempo, sizeof(int), &buffer, &buffer_index); //Envio el paquete a KERNEL if(send(kernelSocketClient, buffer, (size_t) buffer_index, 0) < 0) { log_error(cpu_log, "entrada salida of dispositivo %s %d time send to KERNEL failed", dispositivo, tiempo); } free(buffer); }
static void p_pong(char *from, char **ArgList) { int is_server = 0; int i; if (!ArgList[0]) return; is_server = match("*.*", ArgList[0]); if (in_server_ping && is_server) ; { int old_from_server = from_server; for (i = 0; i < number_of_servers; i++) { if ((!my_stricmp(ArgList[0], get_server_name(i)) || !my_stricmp(ArgList[0], get_server_itsname(i))) && is_server_connected(i)) { int old_lag = server_list[i].lag; from_server = i; server_list[i].lag = time(NULL) - server_list[i].lag_time; in_server_ping--; if (old_lag != server_list[i].lag) status_update(1); from_server = old_from_server; return; } } from_server = old_from_server; } if (check_ignore(from, FromUserHost, NULL, IGNORE_PONGS | IGNORE_CRAP, NULL) != IGNORED) { if (!is_server) return; if (!ArgList[1]) say("%s: PONG received from %s", ArgList[0], from); else say("%s: PING received from %s %s", ArgList[0], from, ArgList[1]); } }
void game_main(){ frame_count = 0; while(373){ /* basic updates */ sprites_clear(); port_read(); actors_update(); status_update(); if(smoke_wait > 0) smoke_wait--; /* vblank */ vsync_wait(); sprites_store(); if(frame_count & 0x01){ store_pattern_name_buffer(1); /* status bar */ } scroll_store(); psg_play(); frame_count++; /* scene status */ switch(scene_type){ case SCENE_GAME_PLAYING: /* game over ? */ if(alive_players == 0){ score_undo(); if(time_left == 0){ scene_type = SCENE_TIME_OVER; gameover_main("- TIME OVER -"); psg_stop(); return; }else{ scene_type = SCENE_GAME_OVER; psg_stop(); return; } } break; case SCENE_GAME_PAUSED: break; case SCENE_DEAD_ALL_ENEMIES: nasu_create_all(); scene_type = SCENE_BONUS; break; case SCENE_BONUS: if(time_left > 0){ score_add_time_bonus(); scene_wait = SCENE_WAIT_INITIAL_VALUE; } if(scene_wait-- == 0){ scene_type = SCENE_GOTO_NEXT_LEVEL; level++; if(level >= LEVEL_COUNT){ level = 0; stage++; if(stage >= STAGE_COUNT){ scene_type = SCENE_ALL_CLEAR; } } score_store(); psg_stop(); return; } break; } } }
void stack_overflow_exit() { printf(ANSI_COLOR_CYAN); log_info(cpu_log, "=== STACK OVERFLOW ==="); printf(ANSI_COLOR_RESET); status_update(BROKEN); }
LRESULT compress(CODEC * codec, ICCOMPRESS * icc) { BITMAPINFOHEADER * inhdr = icc->lpbiInput; BITMAPINFOHEADER * outhdr = icc->lpbiOutput; xvid_enc_frame_t frame; xvid_enc_stats_t stats; int length; memset(&frame, 0, sizeof(frame)); frame.version = XVID_VERSION; frame.type = XVID_TYPE_AUTO; /* vol stuff */ if ((profiles[codec->config.profile].flags & PROFILE_MPEGQUANT) && codec->config.quant_type != QUANT_MODE_H263) { frame.vol_flags |= XVID_VOL_MPEGQUANT; if (codec->config.quant_type == QUANT_MODE_CUSTOM) { frame.quant_intra_matrix = codec->config.qmatrix_intra; frame.quant_inter_matrix = codec->config.qmatrix_inter; }else{ frame.quant_intra_matrix = NULL; frame.quant_inter_matrix = NULL; } } if ((profiles[codec->config.profile].flags & PROFILE_REDUCED) && codec->config.reduced_resolution) { frame.vol_flags |= XVID_VOL_REDUCED_ENABLE; frame.vop_flags |= XVID_VOP_REDUCED; /* XXX: need auto decion mode */ } if ((profiles[codec->config.profile].flags & PROFILE_QPEL) && codec->config.qpel) { frame.vol_flags |= XVID_VOL_QUARTERPEL; frame.motion |= XVID_ME_QUARTERPELREFINE16 | XVID_ME_QUARTERPELREFINE8; } if ((profiles[codec->config.profile].flags & PROFILE_GMC) && codec->config.gmc) { frame.vol_flags |= XVID_VOL_GMC; frame.motion |= XVID_ME_GME_REFINE; } if ((profiles[codec->config.profile].flags & PROFILE_INTERLACE) && codec->config.interlacing) frame.vol_flags |= XVID_VOL_INTERLACING; if (codec->config.ar_mode == 0) { /* PAR */ if (codec->config.display_aspect_ratio != 5) { frame.par = codec->config.display_aspect_ratio + 1; } else { frame.par = XVID_PAR_EXT; frame.par_width = codec->config.par_x; frame.par_height= codec->config.par_y; } } else { /* AR */ /* custom pixel aspect ratio -> calculated from DAR */ frame.par = XVID_PAR_EXT; frame.par_width = (100 * inhdr->biHeight) / codec->config.ar_y; frame.par_height= (100 * inhdr->biWidth) / codec->config.ar_x; } /* vop stuff */ frame.vop_flags |= XVID_VOP_HALFPEL; frame.vop_flags |= XVID_VOP_HQACPRED; if (codec->config.vop_debug) frame.vop_flags |= XVID_VOP_DEBUG; if (codec->config.trellis_quant) { frame.vop_flags |= XVID_VOP_TRELLISQUANT; } if (codec->config.motion_search > 4) frame.vop_flags |= XVID_VOP_INTER4V; if (codec->config.chromame) frame.motion |= XVID_ME_CHROMA_PVOP + XVID_ME_CHROMA_BVOP; if (codec->config.cartoon_mode) { frame.vop_flags |= XVID_VOP_CARTOON; frame.motion |= XVID_ME_DETECT_STATIC_MOTION; } if (codec->config.turbo) frame.motion |= XVID_ME_FASTREFINE16 | XVID_ME_FASTREFINE8 | XVID_ME_SKIP_DELTASEARCH | XVID_ME_FAST_MODEINTERPOLATE | XVID_ME_BFRAME_EARLYSTOP; frame.motion |= pmvfast_presets[codec->config.motion_search]; switch (codec->config.vhq_mode) { case VHQ_MODE_DECISION : frame.vop_flags |= XVID_VOP_MODEDECISION_RD; break; case VHQ_LIMITED_SEARCH : frame.vop_flags |= XVID_VOP_MODEDECISION_RD; frame.motion |= XVID_ME_HALFPELREFINE16_RD; frame.motion |= XVID_ME_QUARTERPELREFINE16_RD; break; case VHQ_MEDIUM_SEARCH : frame.vop_flags |= XVID_VOP_MODEDECISION_RD; frame.motion |= XVID_ME_HALFPELREFINE16_RD; frame.motion |= XVID_ME_HALFPELREFINE8_RD; frame.motion |= XVID_ME_QUARTERPELREFINE16_RD; frame.motion |= XVID_ME_QUARTERPELREFINE8_RD; frame.motion |= XVID_ME_CHECKPREDICTION_RD; break; case VHQ_WIDE_SEARCH : frame.vop_flags |= XVID_VOP_MODEDECISION_RD; frame.motion |= XVID_ME_HALFPELREFINE16_RD; frame.motion |= XVID_ME_HALFPELREFINE8_RD; frame.motion |= XVID_ME_QUARTERPELREFINE16_RD; frame.motion |= XVID_ME_QUARTERPELREFINE8_RD; frame.motion |= XVID_ME_CHECKPREDICTION_RD; frame.motion |= XVID_ME_EXTSEARCH_RD; break; default : break; } frame.input.plane[0] = icc->lpInput; frame.input.stride[0] = (((icc->lpbiInput->biWidth * icc->lpbiInput->biBitCount) + 31) & ~31) >> 3; if ((frame.input.csp = get_colorspace(inhdr)) == XVID_CSP_NULL) return ICERR_BADFORMAT; if (frame.input.csp == XVID_CSP_I420 || frame.input.csp == XVID_CSP_YV12) { frame.input.stride[0] = (4 * icc->lpbiInput->biWidth + 3) / 4; frame.input.stride[1] = frame.input.stride[2] = frame.input.stride[0] / 2 ; } frame.bitstream = icc->lpOutput; frame.length = icc->lpbiOutput->biSizeImage; frame.quant = 0; if (codec->config.mode == RC_MODE_NULL) { outhdr->biSizeImage = 0; *icc->lpdwFlags = AVIIF_KEYFRAME; return ICERR_OK; } // force keyframe spacing in 2-pass 1st pass if (codec->config.motion_search == 0) frame.type = XVID_TYPE_IVOP; /* frame-based stuff */ apply_zone_modifiers(&frame, &codec->config, codec->framenum); /* call encore */ memset(&stats, 0, sizeof(stats)); stats.version = XVID_VERSION; length = codec->xvid_encore_func(codec->ehandle, XVID_ENC_ENCODE, &frame, &stats); switch (length) { case XVID_ERR_FAIL : return ICERR_ERROR; case XVID_ERR_MEMORY : return ICERR_MEMORY; case XVID_ERR_FORMAT : return ICERR_BADFORMAT; case XVID_ERR_VERSION : return ICERR_UNSUPPORTED; } if (codec->config.display_status && stats.type>0) { status_update(&codec->status, stats.type, stats.length, stats.quant); } DPRINTF("{type=%i len=%i} length=%i", stats.type, stats.length, length); if (length == 0) /* no encoder output */ { *icc->lpdwFlags = 0; ((char*)icc->lpOutput)[0] = 0x7f; /* virtual dub skip frame */ outhdr->biSizeImage = 1; }else{ if (frame.out_flags & XVID_KEYFRAME) { codec->keyspacing = 0; *icc->lpdwFlags = AVIIF_KEYFRAME; } else { *icc->lpdwFlags = 0; } outhdr->biSizeImage = length; if (codec->config.mode == RC_MODE_2PASS1 && codec->config.discard1pass) { outhdr->biSizeImage = 0; } } codec->framenum++; codec->keyspacing++; return ICERR_OK; }
int mod (enum einit_module_task task, struct lmodule *module, char *custom_command) { struct einit_event *fb; unsigned int ret; if (!module) return 0; /* wait if the module is already being processed in a different thread */ if (!(task & einit_module_ignore_mutex)) { if ((task & einit_module_suspend) || (task & einit_module_resume)) { if (pthread_mutex_trylock (&module->mutex)) return status_failed; } else emutex_lock (&module->mutex); } if (task & einit_module_suspend) { int retval = mod_suspend (module); if (!(task & einit_module_ignore_mutex)) emutex_unlock (&module->mutex); return retval; } if (task & einit_module_resume) { int retval = mod_resume (module); if (!(task & einit_module_ignore_mutex)) emutex_unlock (&module->mutex); return retval; } if (module->status & status_suspended) { if (!(mod_resume (module) == status_ok)) { if (!(task & einit_module_ignore_mutex)) emutex_unlock (&module->mutex); return status_failed; } } if (task & einit_module_custom) { if (!custom_command) { if (!(task & einit_module_ignore_mutex)) emutex_unlock (&module->mutex); return status_failed; } goto skipdependencies; } if (task & einit_module_ignore_dependencies) { notice (2, "module: skipping dependency-checks"); task ^= einit_module_ignore_dependencies; goto skipdependencies; } if (module->status & MOD_LOCKED) { // this means the module is locked. maybe we're shutting down just now. if (!(task & einit_module_ignore_mutex)) emutex_unlock (&module->mutex); if (task & einit_module_enable) return status_failed; else if (task & einit_module_disable) return status_ok; else return status_ok; } module->status |= status_working; /* check if the task requested has already been done (or if it can be done at all) */ if ((task & einit_module_enable) && (!module->enable || (module->status & status_enabled))) { wontload: module->status ^= status_working; if (!(task & einit_module_ignore_mutex)) emutex_unlock (&module->mutex); return status_idle; } if ((task & einit_module_disable) && (!module->disable || (module->status & status_disabled) || (module->status == status_idle))) goto wontload; if (task & einit_module_enable) { if (!service_usage_query(service_requirements_met, module, NULL)) goto wontload; } else if (task & einit_module_disable) { if (!service_usage_query(service_not_in_use, module, NULL)) goto wontload; } skipdependencies: /* inform everyone about what's going to happen */ { struct einit_event eem = evstaticinit (einit_core_module_update); modules_work_count++; eem.task = task; eem.status = status_working; eem.para = (void *)module; eem.string = (module->module && module->module->rid) ? module->module->rid : module->si->provides[0]; event_emit (&eem, einit_event_flag_broadcast); evstaticdestroy (eem); /* same for services */ if (module->si && module->si->provides) { struct einit_event ees = evstaticinit (einit_core_service_update); ees.task = task; ees.status = status_working; ees.string = (module->module && module->module->rid) ? module->module->rid : module->si->provides[0]; ees.set = (void **)module->si->provides; ees.para = (void *)module; event_emit (&ees, einit_event_flag_broadcast); evstaticdestroy (ees); } } /* actual loading bit */ { fb = evinit (einit_feedback_module_status); fb->para = (void *)module; fb->task = task | einit_module_feedback_show; fb->status = status_working; fb->flag = 0; fb->string = NULL; fb->stringset = (char **)setadd ((void **)NULL, (module->module && module->module->rid) ? module->module->rid : module->si->provides[0], SET_TYPE_STRING); fb->integer = module->fbseq+1; status_update (fb); if (task & einit_module_custom) { if (strmatch (custom_command, "zap")) { char zerror = module->status & status_failed ? 1 : 0; fb->string = "module ZAP'd."; module->status = status_idle; module->status = status_disabled; if (zerror) module->status |= status_failed; } else if (module->custom) { module->status = module->custom(module->param, custom_command, fb); } else { module->status = (module->status & (status_enabled | status_disabled)) | status_failed | status_command_not_implemented; } } else if (task & einit_module_enable) { ret = module->enable (module->param, fb); if (ret & status_ok) { module->status = status_ok | status_enabled; } else { module->status = status_failed | status_disabled; } } else if (task & einit_module_disable) { ret = module->disable (module->param, fb); if (ret & status_ok) { module->status = status_ok | status_disabled; } else { module->status = status_failed | status_enabled; } } fb->status = module->status; module->fbseq = fb->integer + 1; status_update (fb); // event_emit(fb, einit_event_flag_broadcast); // if (fb->task & einit_module_feedback_show) fb->task ^= einit_module_feedback_show; fb->string = NULL; /* module status update */ { struct einit_event eem = evstaticinit (einit_core_module_update); eem.task = task; eem.status = fb->status; eem.para = (void *)module; eem.string = (module->module && module->module->rid) ? module->module->rid : module->si->provides[0]; event_emit (&eem, einit_event_flag_broadcast); evstaticdestroy (eem); /* service status update */ if (module->si && module->si->provides) { struct einit_event ees = evstaticinit (einit_core_service_update); ees.task = task; ees.status = fb->status; ees.string = (module->module && module->module->rid) ? module->module->rid : module->si->provides[0]; ees.set = (void **)module->si->provides; ees.para = (void *)module; event_emit (&ees, einit_event_flag_broadcast); evstaticdestroy (ees); } } free (fb->stringset); evdestroy (fb); service_usage_query(service_update, module, NULL); modules_work_count--; } if (!(task & einit_module_ignore_mutex)) emutex_unlock (&module->mutex); return module->status; }
void process_aborted_exit() { printf(ANSI_COLOR_MAGENTA); log_error(cpu_log, "=== PROCESS ABORTED ==="); printf(ANSI_COLOR_RESET); status_update(ABORTED); }
void service::Connection() { qDebug() << "Parser: Connection"; emit status_update(true); }
void service::Disconnection() { if( connected ) distimer->start(1000); emit status_update(false); qDebug() << "Parser: Disconnection"; }