void rds_tcp_state_change(struct sock *sk) { void (*state_change)(struct sock *sk); struct rds_conn_path *cp; struct rds_tcp_connection *tc; read_lock_bh(&sk->sk_callback_lock); cp = sk->sk_user_data; if (!cp) { state_change = sk->sk_state_change; goto out; } tc = cp->cp_transport_data; state_change = tc->t_orig_state_change; rdsdebug("sock %p state_change to %d\n", tc->t_sock, sk->sk_state); switch (sk->sk_state) { /* ignore connecting sockets as they make progress */ case TCP_SYN_SENT: case TCP_SYN_RECV: break; case TCP_ESTABLISHED: rds_connect_path_complete(cp, RDS_CONN_CONNECTING); break; case TCP_CLOSE_WAIT: case TCP_CLOSE: rds_conn_path_drop(cp); default: break; } out: read_unlock_bh(&sk->sk_callback_lock); state_change(sk); }
static DBusHandlerResult supplicant_filter(DBusConnection *conn, DBusMessage *msg, void *data) { struct supplicant_task *task; const char *member, *path; if (dbus_message_has_interface(msg, SUPPLICANT_INTF ".Interface") == FALSE) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; member = dbus_message_get_member(msg); if (member == NULL) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; path = dbus_message_get_path(msg); if (path == NULL) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; task = find_task_by_path(path); if (task == NULL) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; _DBG_SUPPLICANT("task %p member %s", task, member); if (g_str_equal(member, "ScanResultsAvailable") == TRUE) scan_results_available(task); else if (g_str_equal(member, "Scanning") == TRUE) scanning(task, msg); else if (g_str_equal(member, "StateChange") == TRUE) state_change(task, msg); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; }
void rds_tcp_state_change(struct sock *sk) { void (*state_change)(struct sock *sk); struct rds_connection *conn; struct rds_tcp_connection *tc; read_lock(&sk->sk_callback_lock); conn = sk->sk_user_data; if (conn == NULL) { state_change = sk->sk_state_change; goto out; } tc = conn->c_transport_data; state_change = tc->t_orig_state_change; rdsdebug("sock %p state_change to %d\n", tc->t_sock, sk->sk_state); switch(sk->sk_state) { /* ignore connecting sockets as they make progress */ case TCP_SYN_SENT: case TCP_SYN_RECV: break; case TCP_ESTABLISHED: rds_connect_complete(conn); break; case TCP_CLOSE: rds_conn_drop(conn); default: break; } out: read_unlock(&sk->sk_callback_lock); state_change(sk); }
ENTRYPOINT void draw_voronoi (ModeInfo *mi) { voronoi_configuration *vp = &vps[MI_SCREEN(mi)]; Display *dpy = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); if (!vp->glx_context) return; glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(vp->glx_context)); glShadeModel(GL_FLAT); glEnable(GL_POINT_SMOOTH); /* glEnable(GL_LINE_SMOOTH);*/ /* glEnable(GL_POLYGON_SMOOTH);*/ glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LEQUAL); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); mi->polygon_count = 0; draw_cells (mi); move_points (vp); prune_points (vp); state_change (mi); if (mi->fps_p) do_fps (mi); glFinish(); glXSwapBuffers(dpy, window); }
void ts::scene::Loading_sequence::async_load(const action::Stage* stage) { loaded_scene_ = Scene(); exception_ptr_ = nullptr; stage_ = stage; set_finished(false); set_loading(true); scene_loader_.set_completion_handler([this]() { load_scripts_if_ready(); }); scene_loader_.set_state_change_handler([this](Scene_loader_state new_state) { state_change(to_string(new_state)); }); audio_loader_.set_completion_handler([this]() { load_scripts_if_ready(); }); scene_loader_.async_load(stage, resource_store_->video_settings()); audio_loader_.async_load(stage, resource_store_->audio_settings()); }
void ModuleSequencer::set_state(GxEngineState state) { int newmode = PGN_MODE_MUTE; switch( state ) { case kEngineOn: newmode = PGN_MODE_NORMAL; break; case kEngineBypass: newmode = PGN_MODE_BYPASS; break; case kEngineOff: newmode = PGN_MODE_MUTE; break; } if (audio_mode == newmode) { return; } audio_mode = newmode; set_rack_changed(); state_change(state); }
void rds_tcp_state_change(struct sock *sk) { void (*state_change)(struct sock *sk); struct rds_conn_path *cp; struct rds_tcp_connection *tc; read_lock_bh(&sk->sk_callback_lock); cp = sk->sk_user_data; if (!cp) { state_change = sk->sk_state_change; goto out; } tc = cp->cp_transport_data; state_change = tc->t_orig_state_change; rdsdebug("sock %p state_change to %d\n", tc->t_sock, sk->sk_state); switch (sk->sk_state) { /* ignore connecting sockets as they make progress */ case TCP_SYN_SENT: case TCP_SYN_RECV: break; case TCP_ESTABLISHED: /* Force the peer to reconnect so that we have the * TCP ports going from <smaller-ip>.<transient> to * <larger-ip>.<RDS_TCP_PORT>. We avoid marking the * RDS connection as RDS_CONN_UP until the reconnect, * to avoid RDS datagram loss. */ if (!IS_CANONICAL(cp->cp_conn->c_laddr, cp->cp_conn->c_faddr) && rds_conn_path_transition(cp, RDS_CONN_CONNECTING, RDS_CONN_ERROR)) { rds_conn_path_drop(cp, false); } else { rds_connect_path_complete(cp, RDS_CONN_CONNECTING); } break; case TCP_CLOSE_WAIT: case TCP_CLOSE: rds_conn_path_drop(cp, false); default: break; } out: read_unlock_bh(&sk->sk_callback_lock); state_change(sk); }
/****************************************************************** ** 函数名: TIMy_IRQHandler ** 输 入: none ** 描 述: 该定时器用作检测和LED控制计时使用 ** 全局变量: ** 调用模块: ** 作 者: zcs ** 日 期: 2015-04-21 ** 修 改: ** 日 期: ** 版 本: 1.0 *******************************************************************/ void ReportState(void) { if (state_report_flag) //此时向上层发送状态报告并作心跳检测 { SendStatusReply(current_state); //发送当前状态给上层 state_report_flag = FALSE; //清零状态报告标志位 } if (system_start) { heart_time_count = 0; if (topdeath) { state_change(TopDead); //更改当前状态位上层死机,通信出现故障 topdeath = FALSE; } } }
int main() { int totalTime; totalTime = 0; int quantum; int op; int cpp = 0; pcbCtrl *ctrl; pcbStates *states; groupsCtrl *ctrlG; usersCtrl *ctrlU; ctrl = malloc(sizeof(pcbCtrl)); states = malloc(sizeof(pcbStates)); states->readys = malloc(sizeof(pcbCtrl)); states->waiting = malloc(sizeof(pcbCtrl)); states->sleeping = malloc(sizeof(pcbCtrl)); ctrlG = malloc(sizeof(groupsCtrl)); ctrlU = malloc(sizeof(usersCtrl)); printf("\n"); quantum = set_int("Quantum del programa", 1); if(val_npos(quantum, 1) != FAIL) { do { printf("\n \t\t<< SIMULACION DE ALGORITMO DE DESPACHO RONUD-ROBIN >>\n"); print_options(0); printf("\n>"); scanf("%i",&op); getchar(); switch(op) { case 1: printf("\n"); create_group(ctrlG); break; case 2: printf("\n"); create_user(ctrlU); break; case 3: printf("\n"); create_process(cpp,ctrl,states,ctrlG,ctrlU); cpp++; break; case 4: printf("\n"); state_change(ctrl,states); break; case 5: printf("\n"); show_everything(ctrl,states,ctrlG,ctrlU); break; case 6: printf("\n"); rr(states, ctrl, quantum, &totalTime); break; case 7: printf("\n"); del_option(ctrl,states,ctrlG,ctrlU); break; case 8: break; default: printf("Opcion invalida, vuelva a intentarlo.\n"); } }while(op != 8); if(ctrl->front != NULL) { pcb *aux = ctrl->front; while( next_pcb(&aux,ctrl->front) != FAIL ) free(aux); } if(ctrlG->front != NULL) { groups *aux = ctrlG->front; while( next_group(&aux,ctrlG->front) != FAIL ) free(aux); } if(ctrlU->front != NULL) { users *aux = ctrlU->front; while( next_user(&aux,ctrlU->front) != FAIL ) free(aux); } free(ctrl->front); free(ctrlG->front); free(ctrlU->front); free(ctrl); free(ctrlG); free(ctrlU); } return 0; }
// the kernel bootstrap routine PUBLIC void kernel_thread_t::bootstrap() { // Initializations done -- helping_lock_t can now use helping lock helping_lock_t::threading_system_active = true; // // set up my own thread control block // state_change (0, Thread_running); sched()->set_prio (config::kernel_prio); sched()->set_mcp (config::kernel_mcp); sched()->set_timeslice (config::default_time_slice); sched()->set_ticks_left (config::default_time_slice); present_next = present_prev = this; ready_next = ready_prev = this; // // set up class variables // for (int i = 0; i < 256; i++) prio_next[i] = prio_first[i] = 0; prio_next[config::kernel_prio] = prio_first[config::kernel_prio] = this; prio_highest = config::kernel_prio; timeslice_ticks_left = config::default_time_slice; timeslice_owner = this; // // install our slow trap handler // nested_trap_handler = base_trap_handler; base_trap_handler = thread_handle_trap; // // initialize FPU // set_ts(); // FPU ops -> exception // // initialize interrupts // irq_t::lookup(2)->alloc(this, false); // reserve cascade irq irq_t::lookup(8)->alloc(this, false); // reserve timer irq pic_enable_irq(2); // allow cascaded irqs // set up serial console if (! strstr(kmem::cmdline(), " -I-") && !strstr(kmem::cmdline(), " -irqcom")) { int com_port = console::serial_com_port; int com_irq = com_port & 1 ? 4 : 3; irq_t::lookup(com_irq)->alloc(this, false); // the remote-gdb interrupt pic_enable_irq(com_irq); // for some reason, we have to re-enable the com irq here if (config::serial_esc) com_cons_enable_receive_interrupt(); } // initialize the profiling timer bool user_irq0 = strstr(kmem::cmdline(), "irq0"); if (config::profiling) { if (user_irq0) { kdb_ke("options `-profile' and `-irq0' don't mix " "-- disabling `-irq0'"); } irq_t::lookup(0)->alloc(this, false); profile::init(); if (strstr(kmem::cmdline(), " -profstart")) profile::start(); } else if (! user_irq0) irq_t::lookup(0)->alloc(this, false); // reserve irq0 even though // we don't use it // // set up timer interrupt (~ 1ms) // while (rtcin(RTC_STATUSA) & RTCSA_TUP) ; // wait till RTC ready rtcout(RTC_STATUSA, RTCSA_DIVIDER | RTCSA_1024); // 1024 Hz // set up 1024 Hz interrupt rtcout(RTC_STATUSB, rtcin(RTC_STATUSB) | RTCSB_PINTR | RTCSB_SQWE); rtcin(RTC_INTR); // reset pic_enable_irq(8); // allow this interrupt // // set PCE-Flag in CR4 to enable read of performace measurement counters // in usermode. PMC were introduced in Pentium MMX and PPro processors. // #ifndef CPUF_MMX #define CPUF_MMX 0x00800000 #endif if(strncmp(cpu.vendor_id, "GenuineIntel", 12) == 0 && (cpu.family == CPU_FAMILY_PENTIUM_PRO || cpu.feature_flags & CPUF_MMX)) { set_cr4(get_cr4() | CR4_PCE); } // // allow the boot task to create more tasks // for (unsigned i = config::boot_taskno + 1; i < space_index_t::max_space_number; i++) { check(space_index_t(i).set_chief(space_index(), space_index_t(config::boot_taskno))); } // // create sigma0 // // sigma0's chief is the boot task space_index_t(config::sigma0_id.id.task). set_chief(space_index(), space_index_t(config::sigma0_id.id.chief)); sigma0 = new space_t(config::sigma0_id.id.task); sigma0_thread = new (&config::sigma0_id) thread_t (sigma0, &config::sigma0_id, config::sigma0_prio, config::sigma0_mcp); // push address of kernel info page to sigma0's stack vm_offset_t esp = kmem::info()->sigma0_esp; * reinterpret_cast<vm_offset_t*>(kmem::phys_to_virt(--esp)) = kmem::virt_to_phys(kmem::info()); sigma0_thread->initialize(kmem::info()->sigma0_eip, esp, 0, 0); // // create the boot task // // the boot task's chief is the boot task itself space_index_t(config::boot_id.id.task). set_chief(space_index(), space_index_t(config::boot_id.id.chief)); space_t *boot = new space_t(config::boot_id.id.task); thread_t *boot_thread = new (&config::boot_id) thread_t (boot, &config::boot_id, config::boot_prio, config::boot_mcp); boot_thread->initialize(0x200000, 0x200000, sigma0_thread, 0); // // the idle loop // for (;;) { // printf("I"); sti(); // enable irqs, otherwise idling is fatal if (config::hlt_works_ok) asm("hlt"); // stop the CPU, waiting for an int while (ready_next != this) // are there any other threads ready? schedule(); } }