void mu_signal_process(char *command, int signal) { boolean_t pid_present, name_present; int4 pid, length, status, item, outv; char prc_nam[20]; unsigned short name_len; $DESCRIPTOR(d_prc_nam,""); memset(prc_nam, 0, SIZEOF(prc_nam)); pid_present = name_present = FALSE; if (cli_present("id") == CLI_PRESENT) { if(!cli_get_hex("id", &pid)) return; pid_present = TRUE; } if (cli_present("name") == CLI_PRESENT) { name_len = 20; if (!cli_get_str("name", prc_nam, &name_len)) return; if (prc_nam[name_len-1] == '"') name_len--; if (prc_nam[0] == '"') { d_prc_nam.dsc$a_pointer = &prc_nam[1]; name_len--; } else d_prc_nam.dsc$a_pointer = &prc_nam; d_prc_nam.dsc$w_length = name_len; name_present = TRUE; } if (!name_present) { if (SS$_NORMAL == send_signal(pid, signal)) SENDMSG_OUTPUT("", pid); return; } item = JPI$_PID; status = lib$getjpi(&item, 0, &d_prc_nam, &outv, 0, 0); if (SS$_NORMAL != status) { rts_error(VARLSTCNT(1) status); return; } if (!pid_present) { if (SS$_NORMAL == send_signal(outv, signal)) SENDMSG_OUTPUT(&prc_nam, outv); return; } if (outv != pid) { util_out_print("ID !XL and NAME !AD are not the same process", FLUSH, pid, LEN_AND_STR(&prc_nam)); return; } if (SS$_NORMAL == send_signal(pid, signal)) SENDMSG_OUTPUT(&prc_nam, pid); return; }
void send_signals() { printf("Sending %d SIGRTMIN signals to catcher...\n", signal_num); for (int i = 0; i < signal_num; i++) send_signal(catcher_pid, SIGRTMIN); printf("Sending SIGRTMIN+1 to catcher...\n"); send_signal(catcher_pid, SIGRTMIN + 1); }
void send_signals(int signal_num, pid_t sender_pid) { sigusr1_received = 0; for (int i = 0; i < signal_num; i++) { send_signal(sender_pid, SIGUSR1); while (!sigusr1_received); sigusr1_received = 0; } send_signal(sender_pid, SIGUSR2); }
void pacemaker_avi(void const *i) { volatile static int state = IdleAVI; while(1) { switch(state) { case IdleAVI: { ////////pc.printf("\nIdleAVI"); osEvent evt = Thread::signal_wait(0); Thread::wait(1); if(evt.value.signals & Apace || evt.value.signals & Asense) { //////////pc.printf("\nAP/AS"); x_clock.reset(); state = AVI; } break; } case AVI: { osEvent evt; evt = Thread::signal_wait(Vsense, t_avi - x_clock.read_ms()); Thread::wait(1); if(evt.value.signals & Vsense) { state = IdleAVI; } else if(x_clock.read_ms() >= t_avi && clk_clock.read_ms() >= t_uri) { pc.printf("\nAVI Vpace%i:", test_clock.read_ms()); send_signal(Vpace); state = IdleAVI; } else if(x_clock.read_ms() >= t_avi && clk_clock.read_ms() < t_uri) { state = WaitURI; } break; } case WaitURI: { ////////pc.printf("\nWaitURI"); osEvent evt = Thread::signal_wait(Vsense, t_uri - clk_clock.read_ms() ); Thread::wait(1); if(evt.value.signals & Vsense) { state = IdleAVI; } else if(clk_clock.read_ms() >= t_uri ) { send_signal(Vpace); pc.printf("\nAVI Vpace%i:", test_clock.read_ms()); state = IdleAVI; } break; } default: { state = IdleAVI; } } } }
int main(int argc, char *argv[]) { int client_flag, server_cmd; if (!connect_server()) { qDebug() << "Not connected control server!"; return 1; } else { qDebug() << "Connected to control server!"; } if (!connect_psdb()) { qDebug() << "Not connected parameter server database!"; return 1; } else { qDebug() << "Connected to parameter server database!"; } while (1) { server_cmd = request_cmd(); switch (server_cmd) { case cmd_work: client_flag = execute_evo_motor(); break; case cmd_term: qDebug() << "cmd_exit"; break; default: qDebug() << "error exit"; break; } switch (client_flag) { case flag_success: send_signal(flag_success); break; case flag_failure: default: qDebug() << "flag_failure"; send_signal(flag_failure); break; } } return 0; }
uint8 i2c_ReadByte(uint8 SlaveAddress,uint8 AccessAddress,uint8 *Data) { I2C0_C1 |= 0x10; //TX = 1,MCU设置为发送模式 send_signal('S'); //发送开始信号 I2C0_D = SlaveAddress & 0xfe; //发送设备地址,并通知从机接收数据 if(i2c_wait('T')) //等待一个字节数据传送完成 { return 1; //没有传送成功,读一个字节失败 } if (i2c_wait('A')) //等待从机应答信号 { return 1; //没有等到应答信号,读一个字节失败 } I2C0_D = AccessAddress; //发送访问地址 if (i2c_wait('T')) //等待一个字节数据传送完成 { return 1; //没有传送成功,读一个字节失败 } if (i2c_wait('A')) //等待从机应答信号 { return 1; //没有等到应答信号,读一个字节失败 } pause(); I2C0_C1 |= 0x04;//当MCU在主机模 式下,向该位写1将产生一个重新开始信号 I2C0_D = SlaveAddress | 0x01; //通知从机改为发送数据 if (i2c_wait('T')) //等待一个字节数据传送完成 { return 1; //没有传送成功,读一个字节失败 } if (i2c_wait('A')) //等待从机应答信号 { return 1; //没有等到应答信号,读一个字节失败 } I2C0_C1 &= 0xef; //TX = 0,MCU设置为接收模式 *Data = I2C0_D; //读出IIC1D,准备接收数据 if (i2c_wait('T')) //等待一个字节数据传送完成 { return 1; //没有传送成功,读一个字节失败 } send_signal('O'); //发送停止信号 *Data = I2C0_D; //读出接收到的一个数据 pause(); return 0; //正确接收到一个字节数据 }
static void ep_ready(int txid, int status) { struct transaction_data *data = NULL; if (txid == 0) return; /* find the correct transaction data structure */ data = ep_get_transaction(txid); if (data) { #if 0 printf("libep: decreasing data '%p' reference count from '%u' to '%u'\n", data, data->refcount, data->refcount - 1); #endif data->refcount--; if ((data->refcount == 0 && data->ready) || !status) { /* all callbacks have returned true or one has failed */ send_signal(txid, status); ep_list_remove(&transaction_list, data); free(data); data = NULL; } } return; }
int sock_send_signal(int purpose,int sig) { if (accept_if_needed(purpose) != -1) return send_signal(purpose_table[purpose], sig); return -1; }
void pacemaker_vrp(void const *i) { volatile static int state = IdleVRP; while(1) { switch(state) { case IdleVRP: { //pc.printf("\nIdleVRP%i",test_clock.read_ms()); osEvent evt = Thread::signal_wait(0); Thread::wait(1); if(evt.value.signals & Vsignal) { pc.printf("\n Vsignal Rec"); send_signal(Vsense); x_clock.reset(); state = VRP; } else if(evt.value.signals & Vpace) { x_clock.reset(); state = VRP; } break; } case VRP: { if( x_clock.read_ms() < t_vrp) { Thread::wait(t_vrp - x_clock.read_ms()); } else if( x_clock.read_ms() >= t_vrp) { state = IdleVRP; } break; } default: { state = IdleVRP; } } } }
void original_getinfo() { passnumber=1; send_signal(); sleep(3); passnumber=0; }
static void ps7500_update_intr (void *mach) { struct machine_config *mc = (struct machine_config *) mach; void *state = (void *) mc->state; #if 0 state->NfiqSig = (io.fiq[FIQ] & io.fiqmask[FIQ]) ? LOW : HIGH; state->NirqSig = ((io.irq[IRQA] & io.irqmask[IRQA]) || (io.irq[IRQB] & io.irqmask[IRQB]) || (io.irq[IRQC] & io.irqmask[IRQC]) || (io.irq[IRQD] & io.irqmask[IRQD]) || (io.irq[IRQDMA] & io.irqmask[IRQDMA])) ? LOW : HIGH; #endif interrupt_signal_t interrupt_signal; interrupt_signal.arm_signal.reset = Prev_level; interrupt_signal.arm_signal.firq = (io.fiq[FIQ] & io.fiqmask[FIQ]) ? Low_level : High_level; interrupt_signal.arm_signal.irq = ((io.irq[IRQA] & io.irqmask[IRQA]) || (io.irq[IRQB] & io.irqmask[IRQB]) || (io.irq[IRQC] & io.irqmask[IRQC]) || (io.irq[IRQD] & io.irqmask[IRQD]) || (io.irq[IRQDMA] & io.irqmask[IRQDMA])) ? Low_level : High_level; send_signal(&interrupt_signal); }
static void ps7500_update_int(void *state) { int i; //if (io.irq[IRQB] & io.net_int[IRQB]) { // printf("Network interrupt set\n"); // for (i=0; i < 5; i++) { // printf("IRQ[%d] %02x IRQMASK[%d] %02x\n", // i, io.irq[i], i, io.irqmask[i]); // } //} #if 0 state->NfiqSig = (io.fiq[FIQ] & io.fiqmask[FIQ]) ? LOW : HIGH; state->NirqSig = ((io.irq[IRQA] & io.irqmask[IRQA]) || (io.irq[IRQB] & io.irqmask[IRQB]) || (io.irq[IRQC] & io.irqmask[IRQC]) || (io.irq[IRQD] & io.irqmask[IRQD]) || (io.irq[IRQDMA] & io.irqmask[IRQDMA])) ? LOW : HIGH; #endif interrupt_signal_t interrupt_signal; interrupt_signal.arm_signal.reset = Prev_level; interrupt_signal.arm_signal.firq = (io.fiq[FIQ] & io.fiqmask[FIQ]) ? Low_level : High_level; interrupt_signal.arm_signal.irq = ((io.irq[IRQA] & io.irqmask[IRQA]) || (io.irq[IRQB] & io.irqmask[IRQB]) || (io.irq[IRQC] & io.irqmask[IRQC]) || (io.irq[IRQD] & io.irqmask[IRQD]) || (io.irq[IRQDMA] & io.irqmask[IRQDMA])) ? Low_level : High_level; send_signal(&interrupt_signal); }
void child_main() { // Ignore control-C in child setup_signal_handling(SIGINT, SIG_IGN); // Create the message queue msg_queue_id = msgget(MESSAGE_QUEUE_KEY, 0666 | IPC_CREAT); if (msg_queue_id == -1) { // Invalid message queue dump("Failed to open/create controller queue."); send_signal(SIGTERM, true); return; } while(running) { child_loop(); } // Delete the message queue dump("Removing message queue"); if (-1 == msgctl(msg_queue_id, IPC_RMID, 0)) { dump("Failed to delete message queue"); } dump("Finished"); }
static void omap5912_update_int (void *state) { //uart1 and os timer int is mapped to l2 int uint32_t requests; //printf("irq sig initial: %x\n", state->NirqSig); omap5912_update_l2_int(state); //printf(" here test mpu1_itr data = %x\n", omap5912_io.ic.mpu_l1_itr); requests = omap5912_io.ic.mpu_l1_itr & ((~omap5912_io.ic.mpu_l1_mir) & 0xffffffff); //printf("requests %x\n",requests); #if 0 state->NirqSig = (requests) ? LOW : HIGH; state->NfiqSig = HIGH; #endif interrupt_signal_t interrupt_signal; interrupt_signal.arm_signal.firq = High_level; interrupt_signal.arm_signal.reset = Prev_level; interrupt_signal.arm_signal.irq = (requests) ? Low_level : High_level; send_signal(&interrupt_signal); //printf("irq sig in l1:%x\n", state->NirqSig); }
void sys_raise(struct cpu_state **cpu) { unsigned int sig = (*cpu)->CPU_ARG1; send_signal(current_thread->process, sig); (*cpu)->CPU_ARG0 = 0; }
uint32_t write_pipe(fs_node_t *node, uint32_t offset, uint32_t size, uint8_t *buffer) { assert(node->device != 0 && "Attempted to write to a fully-closed pipe."); /* Retreive the pipe object associated with this file node */ pipe_device_t * pipe = (pipe_device_t *)node->device; #if DEBUG_PIPES if (pipe->size > 300) { /* Ignore small pipes (ie, keyboard) */ debug_print(INFO, "[debug] Call to write to pipe 0x%x", node->device); debug_print(INFO, " Available space: %d", pipe_available(pipe)); debug_print(INFO, " Total size: %d", pipe->size); debug_print(INFO, " Request size: %d", size); debug_print(INFO, " Write pointer: %d", pipe->write_ptr); debug_print(INFO, " Read pointer: %d", pipe->read_ptr); debug_print(INFO, " Buffer address: 0x%x", pipe->buffer); debug_print(INFO, " Write: %s", buffer); } #endif if (pipe->dead) { debug_print(WARNING, "Pipe is dead?"); send_signal(getpid(), SIGPIPE); return 0; } size_t written = 0; while (written < size) { spin_lock(pipe->lock_write); #if 0 size_t available = 0; if (pipe->read_ptr <= pipe->write_ptr) { available = pipe->size - pipe->write_ptr; } else { available = pipe->read_ptr - pipe->write_ptr - 1; } if (available) { available = min(available, size - written); memcpy(&pipe->buffer[pipe->write_ptr], buffer, available); pipe_increment_write_by(pipe, available); written += available; } #else while (pipe_available(pipe) > 0 && written < size) { pipe->buffer[pipe->write_ptr] = buffer[written]; pipe_increment_write(pipe); written++; } #endif spin_unlock(pipe->lock_write); wakeup_queue(pipe->wait_queue_readers); pipe_alert_waiters(pipe); if (written < size) { sleep_on(pipe->wait_queue_writers); } } return written; }
/* * --------------------------------------------------------------------------- * unifi_send_signal * * Invokes send_signal() to queue a signal in the command or traffic queue * If sigptr pointer is NULL, it pokes the bh to check if UniFi is responsive. * * Arguments: * card Pointer to card context struct * sigptr Pointer to signal from card. * siglen Size of the signal * bulkdata Pointer to the bulk data of the signal * * Returns: * CSR_RESULT_SUCCESS on success * CSR_WIFI_HIP_RESULT_NO_SPACE if there were insufficient data slots or no free signal queue entry * * Notes: * unifi_send_signal() is used to queue signals, created by the driver, * to the device. Signals are constructed using the UniFi packed structures. * --------------------------------------------------------------------------- */ CsrResult unifi_send_signal(card_t *card, const CsrUint8 *sigptr, CsrUint32 siglen, const bulk_data_param_t *bulkdata) { q_t *sig_soft_q; CsrUint16 signal_id; CsrResult r; CsrUint32 run_bh; CsrUint32 priority_q; /* A NULL signal pointer is a request to check if UniFi is responsive */ if (sigptr == NULL) { card->bh_reason_host = 1; return unifi_run_bh(card->ospriv); } priority_q = 0; run_bh = 1; signal_id = GET_SIGNAL_ID(sigptr); /* * If the signal is a CSR_MA_PACKET_REQUEST , * we send it using the traffic soft queue. Else we use the command soft queue. */ if (signal_id == CSR_MA_PACKET_REQUEST_ID) { CsrUint16 frame_priority; if (card->periodic_wake_mode == UNIFI_PERIODIC_WAKE_HOST_ENABLED) { run_bh = 0; } #if defined (CSR_WIFI_HIP_DEBUG_OFFLINE) && defined (CSR_WIFI_HIP_DATA_PLANE_PROFILE) unifi_debug_log_to_buf("D"); #endif /* Sanity check: MA-PACKET.req must have a valid bulk data */ if ((bulkdata->d[0].data_length == 0) || (bulkdata->d[0].os_data_ptr == NULL)) { unifi_error(card->ospriv, "MA-PACKET.req with empty bulk data (%d bytes in %p)\n", bulkdata->d[0].data_length, bulkdata->d[0].os_data_ptr); dump((void *)sigptr, siglen); return CSR_RESULT_FAILURE; } /* Map the frame priority to a traffic queue index. */ frame_priority = GET_PACKED_MA_PACKET_REQUEST_FRAME_PRIORITY(sigptr); priority_q = unifi_frame_priority_to_queue((CSR_PRIORITY)frame_priority); sig_soft_q = &card->fh_traffic_queue[priority_q]; } else { sig_soft_q = &card->fh_command_queue; } r = send_signal(card, sigptr, siglen, bulkdata, sig_soft_q, priority_q, run_bh); /* On error, the caller must free or requeue bulkdata buffers */ return r; } /* unifi_send_signal() */
void parent_loop() { // Wait to get instruction from controller dump("Waiting for instruction from controller"); int monitor_fifo_fd = open(monitor_fifo_name, O_RDONLY); if (-1 == monitor_fifo_fd) { unlink(monitor_fifo_name); if (EINTR != errno) { dump("Failed to open monitor fifo with error: %d", errno); } return; } // Read the response fifo_data fdata; if (-1 == read(monitor_fifo_fd, &fdata, sizeof(fdata))) { unlink(monitor_fifo_name); if (EINTR != errno) { dump("Failed to read monitor fifo with error: %d", errno); } return; } // Check if we got the go ahead switch(fdata.request_type) { case STOP: dump("Received stop command from controller"); send_signal(SIGTERM, true); return; default: dump("Invalid response received from controller"); return; } }
/* This is called by the lower half when a break is received. */ void input_break () { struct queue **qp = termstate.c_lflag & ICANON ? &rawq : &inputq; /* Don't do anything if IGNBRK is set. */ if (termstate.c_iflag & IGNBRK) return; /* If BRKINT is set, then flush queues and send SIGINT. */ if (termstate.c_iflag & BRKINT) { drop_output (); /* XXX drop pending input How?? */ send_signal (SIGINT); return; } /* A break is then read as a null byte; marked specially if PARMRK is set. */ if (termstate.c_iflag & PARMRK) { enqueue_quote (qp, CHAR_USER_QUOTE); enqueue_quote (qp, '\0'); } enqueue_quote (qp, '\0'); }
int main (void) { // enable pull up resistors bset(PORTB, 1); bset(PORTB, 2); bset(PORTB, 3); // burn some time to let inputs settle __builtin_avr_delay_cycles(20); // this is a really inefficent way to do it, but i had the I/Os // and a free 4 position switch, so why not. simpler than binary input. // to read, all pull ups are enabled, and each pin of the switch // is connected to a seperate IO. the IO that is low is switch pos uint16_t delay = 60; // assume position 1 by default // could use uint8_t and save some code space // divide each delay by 4, then then delay for 4000ms in the loop if (!bisset(PINB,3)) // position 2 delay = 120; if (!bisset(PINB,1)) // position 3 delay = 180; if (!bisset(PINB,2)) // position 4 delay = 300; PORTB = 0; // disable pull ups // enable output bset(DDRB, 0); while(true) { send_signal(); // begin bulb exposure // this is wasteful of power, but i tried using the wdt // to let me sleep 1s in power down state, and it turns // out that the wdt oscilator is way off. better to busy // wait and be about correct than way out in left field for(uint16_t i = 0; i <= delay; i++) _delay_ms(1000); send_signal(); // terminate bulb exposure _delay_ms(10000); // wait for camera to recover its wits } }
void *get_data() { sleep(1); printf("get information\n"); send_signal(); sleep(2); passnumber=0; pthread_exit(0); }
int send_wakeup(Sock *sock) { #ifdef SIGUSR1 return send_signal(sock, SIGUSR1); #else return -1; #endif }
int main(int argc, const char * argv[]) { // insert code here... int ret=send_signal(6561); if(ret>0) std::cout<<"The process whose identifier is pid."<<std::endl; else if (ret==0) std::cout<<"All processes in the same process group as the sender."<<std::endl; else if (ret==-1) std::cout<<"If the process is privileged, send the signal to all processes except for some special system processes. Otherwise, send the signal to all processes with the same effective user ID."<<std::endl; else std::cout<<"The process group whose identifier is -pid."<<std::endl; return 0; }
int ProcFamily::spree_cgroup(int sig) { // The general idea here is we freeze the cgroup, give the signal, // then thaw everything out. This way, signals are given in an atomic manner. // // Note that if the FREEZE call could be attempted, but not 100% completed, we // proceed anyway. bool use_freezer = !m_last_signal_was_sigstop; m_last_signal_was_sigstop = sig == SIGSTOP ? true : false; if (!use_freezer) { dprintf(D_ALWAYS, "Not using freezer controller to send signal; last " "signal was SIGSTOP.\n"); } else { dprintf(D_FULLDEBUG, "Using freezer controller to send signal to process family.\n"); } int err = use_freezer ? freezer_cgroup(FROZEN) : 0; if ((err != 0) && (err != -EBUSY)) { return err; } ASSERT (m_cgroup.isValid()); cgroup_get_cgroup(&const_cast<struct cgroup&>(m_cgroup.getCgroup())); void **handle = (void **)malloc(sizeof(void*)); ASSERT (handle != NULL); pid_t pid; err = cgroup_get_task_begin(m_cgroup_string.c_str(), FREEZE_CONTROLLER_STR, handle, &pid); if ((err > 0) && (err != ECGEOF)) handle = NULL; while (err != ECGEOF) { if (err > 0) { dprintf(D_ALWAYS, "Unable to iterate through cgroup %s (ProcFamily %u): %u %s\n", m_cgroup_string.c_str(), m_root_pid, err, cgroup_strerror(err)); goto release; } send_signal(pid, sig); err = cgroup_get_task_next(handle, &pid); } err = 0; release: if (handle != NULL) { cgroup_get_task_end(handle); free(handle); } if (use_freezer) freezer_cgroup(THAWED); return err; }
void handle_signal(int sigtype) { if (SIGINT == sigtype) { dump("Received SIGINT signal"); running = false; if (is_parent()) { send_signal(SIGTERM, false); } } else if (SIGTERM == sigtype) { dump("Received SIGTERM signal"); running = false; if (is_parent()) { send_signal(SIGTERM, false); } } else { dump("Received unknown signal. Ignoring it"); } }
void RemoteDispatcher::run () { if( !m_running && !m_pendingSignals.isEmpty() ) { NLog::global()->add_message( QString("Executing %1 frame(s)") .arg(m_pendingSignals.count()) ); m_nextIndex = 1; m_running = true; send_signal(0); } }
/* * sigint_handler - The kernel sends a SIGINT to the shell whenver the * user types ctrl-c at the keyboard. Catch it and send it along * to the foreground job. */ void sigint_handler(int sig) { pid_t pid = fgpid(jobs); int jid = pid2jid(pid); if (pid != 0) { printf("Jobs [%d] (%d) terminated by signal %d\n", jid, pid, sig); deletejob(jobs, pid); send_signal(-pid, sig); } }
/* * sigtstp_handler - The kernel sends a SIGTSTP to the shell whenever * the user types ctrl-z at the keyboard. Catch it and suspend the * foreground job by sending it a SIGTSTP. */ void sigtstp_handler(int sig) { pid_t pid = fgpid(jobs); int jid = pid2jid(pid); if (pid != 0) { printf("Job [%d] (%d) stopped by signal %d\n", jid, pid, sig); getjobpid(jobs, pid)->state = ST; send_signal(-pid, sig); } }
void ProcFamily::signal_root(int sig) { #if !defined(WIN32) if (m_proxy != NULL) { glexec_kill(m_proxy, m_root_pid, sig); return; } #endif send_signal(m_root_pid, sig); }
status_t ExpanderThread::ResumeExternalExpander() { thread_info info; status_t status = get_thread_info(fThreadId, &info); if (status == B_OK) return send_signal(-fThreadId, SIGCONT); else return status; }