本文整理汇总了C++中show_state函数的典型用法代码示例。如果您正苦于以下问题:C++ show_state函数的具体用法?C++ show_state怎么用?C++ show_state使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了show_state函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: SendACKFun
void SendACKFun(void *ptr)
{
printf("create send ack thread\n");
char ackframe[7] = "*00ACK/";
while(1)
{
if(needsendACK == 1)
{
printf("sending ACK frame....\n");
SendFrame(fd, ackframe, 7);
needsendACK = 0;
show_state();
}
usleep(100);
}
}
开发者ID:ShelmyLin,项目名称:ISIMA_Embedded_Linux_Project,代码行数:16,代码来源:Sensor.c
示例2: dump_syscall_tables_uniarch
void dump_syscall_tables_uniarch(void)
{
unsigned int i;
outputstd("syscalls: %d\n", max_nr_syscalls);
for_each_syscall(i) {
outputstd("entrypoint %d %s : ",
syscalls[i].entry->number,
syscalls[i].entry->name);
show_state(syscalls[i].entry->flags & ACTIVE);
if (syscalls[i].entry->flags & AVOID_SYSCALL)
outputstd(" AVOID");
outputstd("\n");
}
}
开发者ID:po1inom,项目名称:trinity,代码行数:16,代码来源:tables-uniarch.c
示例3: mac_nmi_handler
irqreturn_t mac_nmi_handler(int irq, void *dev_id, struct pt_regs *fp)
{
int i;
/*
* generate debug output on NMI switch if 'debug' kernel option given
* (only works with Penguin!)
*/
in_nmi++;
for (i=0; i<100; i++)
udelay(1000);
if (in_nmi == 1) {
nmi_hold = 1;
printk("... pausing, press NMI to resume ...");
} else {
printk(" ok!\n");
nmi_hold = 0;
}
barrier();
while (nmi_hold == 1)
udelay(1000);
if ( console_loglevel >= 8 ) {
#if 0
show_state();
printk("PC: %08lx\nSR: %04x SP: %p\n", fp->pc, fp->sr, fp);
printk("d0: %08lx d1: %08lx d2: %08lx d3: %08lx\n",
fp->d0, fp->d1, fp->d2, fp->d3);
printk("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
fp->d4, fp->d5, fp->a0, fp->a1);
if (STACK_MAGIC != *(unsigned long *)current->kernel_stack_page)
printk("Corrupted stack page\n");
printk("Process %s (pid: %d, stackpage=%08lx)\n",
current->comm, current->pid, current->kernel_stack_page);
if (intr_count == 1)
dump_stack((struct frame *)fp);
#else
/* printk("NMI "); */
#endif
}
in_nmi--;
return IRQ_HANDLED;
}
开发者ID:sarnobat,项目名称:knoppix,代码行数:47,代码来源:macints.c
示例4: receive_chars
static void receive_chars(struct m68k_serial *info, unsigned short rx)
{
m68328_uart *uart = &uart_addr[info->line];
unsigned char ch, flag;
/*
* This do { } while() loop will get ALL chars out of Rx FIFO
*/
#ifndef CONFIG_XCOPILOT_BUGS
do {
#endif
ch = GET_FIELD(rx, URX_RXDATA);
if(info->is_cons) {
if(URX_BREAK & rx) { /* whee, break received */
return;
#ifdef CONFIG_MAGIC_SYSRQ
} else if (ch == 0x10) { /* ^P */
show_state();
show_free_areas(0);
show_buffers();
/* show_net_buffers(); */
return;
} else if (ch == 0x12) { /* ^R */
emergency_restart();
return;
#endif /* CONFIG_MAGIC_SYSRQ */
}
}
flag = TTY_NORMAL;
if (rx & URX_PARITY_ERROR)
flag = TTY_PARITY;
else if (rx & URX_OVRUN)
flag = TTY_OVERRUN;
else if (rx & URX_FRAME_ERROR)
flag = TTY_FRAME;
tty_insert_flip_char(&info->tport, ch, flag);
#ifndef CONFIG_XCOPILOT_BUGS
} while((rx = uart->urx.w) & URX_DATA_READY);
#endif
tty_schedule_flip(&info->tport);
}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:46,代码来源:68328serial.c
示例5: panic_print_sys_info
static void panic_print_sys_info(void)
{
if (panic_print & PANIC_PRINT_TASK_INFO)
show_state();
if (panic_print & PANIC_PRINT_MEM_INFO)
show_mem(0, NULL);
if (panic_print & PANIC_PRINT_TIMER_INFO)
sysrq_timer_list_show();
if (panic_print & PANIC_PRINT_LOCK_INFO)
debug_show_all_locks();
if (panic_print & PANIC_PRINT_FTRACE_INFO)
ftrace_dump(DUMP_ALL);
}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:17,代码来源:panic.c
示例6: show_event
static void show_event(int index) {
int screen_count = s_active_item_count + 1;
int height = bounds.size.h * (screen_count + 2);
destroy_property_animation(&prop_animation);
bool invert = false;
GRect from_rect = GRect(0, -(current_item + 1) * bounds.size.h, bounds.size.w, height);
if(index < 0) {
index = screen_count - 1;
from_rect.origin.y = -(screen_count + 1) * bounds.size.h;
invert = true;
}
else if(index >= screen_count) {
index = 0;
from_rect.origin.y = 0;
invert = true;
}
GRect to_rect = GRect(0, -(index + 1) * bounds.size.h, bounds.size.w, height);
prop_animation = property_animation_create_layer_frame(events_layer, &from_rect, &to_rect);
animation_set_duration((Animation*) prop_animation, 400);
animation_schedule((Animation*) prop_animation);
// if state is about to be shown or hidden then animate it
if (index == 0 || current_item == 0) {
int stateFrom = 0, stateTo = 0;
if (current_item == 1)
stateFrom = -1;
else if (current_item > 1)
stateFrom = 1;
if (index == 1)
stateTo = -1;
else if (index > 1)
stateTo = 1;
if (invert && screen_count == 2) {
stateFrom = -stateFrom;
stateTo = -stateTo;
}
show_state(stateFrom, stateTo);
}
current_item = index;
layer_mark_dirty(navi_layer);
}
开发者ID:technicallyfeasible,项目名称:KeepzerPebble,代码行数:44,代码来源:main.c
示例7: nmi_debug_notify
static int nmi_debug_notify(struct notifier_block *self,
unsigned long val, void *data)
{
struct die_args *args = data;
if (likely(val != DIE_NMI))
return NOTIFY_DONE;
if (nmi_actions & NMI_SHOW_STATE)
show_state();
if (nmi_actions & NMI_SHOW_REGS)
show_regs(args->regs);
if (nmi_actions & NMI_DEBOUNCE)
mdelay(10);
if (nmi_actions & NMI_DIE)
return NOTIFY_BAD;
return NOTIFY_OK;
}
开发者ID:274914765,项目名称:C,代码行数:19,代码来源:nmi_debug.c
示例8: i2c_pxa_handler
static irqreturn_t i2c_pxa_handler(int this_irq, void *dev_id)
{
struct pxa_i2c *i2c = dev_id;
u32 isr = readl(_ISR(i2c));
if (i2c_debug > 2 && 0) {
dev_dbg(&i2c->adap.dev, "%s: ISR=%08x, ICR=%08x, IBMR=%02x\n",
__func__, isr, readl(_ICR(i2c)), readl(_IBMR(i2c)));
decode_ISR(isr);
}
if (i2c->irqlogidx < ARRAY_SIZE(i2c->isrlog))
i2c->isrlog[i2c->irqlogidx++] = isr;
show_state(i2c);
/*
* Always clear all pending IRQs.
*/
writel(isr & (ISR_SSD|ISR_ALD|ISR_ITE|ISR_IRF|ISR_SAD|ISR_BED), _ISR(i2c));
if (isr & ISR_SAD)
i2c_pxa_slave_start(i2c, isr);
if (isr & ISR_SSD)
i2c_pxa_slave_stop(i2c);
if (i2c_pxa_is_slavemode(i2c)) {
if (isr & ISR_ITE)
i2c_pxa_slave_txempty(i2c, isr);
if (isr & ISR_IRF)
i2c_pxa_slave_rxfull(i2c, isr);
} else if (i2c->msg) {
if (isr & ISR_ITE)
i2c_pxa_irq_txempty(i2c, isr);
if (isr & ISR_IRF)
i2c_pxa_irq_rxfull(i2c, isr);
} else {
i2c_pxa_scream_blue_murder(i2c, "spurious irq");
}
return IRQ_HANDLED;
}
开发者ID:StephenMacras,项目名称:dsl-n55u-bender,代码行数:42,代码来源:i2c-pxa.c
示例9: i2c_vr_abort
static void i2c_vr_abort(struct vr_i2c *i2c)
{
struct i2c_vr_regs __iomem *regs = i2c->regs;
unsigned long timeout = jiffies + HZ / 4;
u32 icr;
while (time_before(jiffies, timeout) && (readl(®s->ibmr) & 0x1) == 0) {
icr = readl(®s->icr);
icr &= ~ICR_START;
icr |= ICR_ACKNAK | ICR_STOP | ICR_TB;
writel(icr, ®s->icr);
show_state(i2c);
msleep(1);
}
icr = readl(®s->icr) & ~(ICR_MA | ICR_START | ICR_STOP);
writel(icr, ®s->icr);
}
开发者ID:prime5711,项目名称:blackbox,代码行数:22,代码来源:i2c-vr.c
示例10: receive_chars
static void receive_chars(struct tty_struct *tty, struct pt_regs *regs)
{
unsigned char ch;
static unsigned char seen_esc = 0;
while ( (ch = ia64_ssc(0, 0, 0, 0, SSC_GETCHAR)) ) {
if ( ch == 27 && seen_esc == 0 ) {
seen_esc = 1;
continue;
} else {
if ( seen_esc==1 && ch == 'O' ) {
seen_esc = 2;
continue;
} else if ( seen_esc == 2 ) {
if ( ch == 'P' ) show_state(); /* F1 key */
#ifdef CONFIG_KDB
if ( ch == 'S' )
kdb(KDB_REASON_KEYBOARD, 0, (kdb_eframe_t) regs);
#endif
seen_esc = 0;
continue;
}
}
seen_esc = 0;
if (tty->flip.count >= TTY_FLIPBUF_SIZE) break;
*tty->flip.char_buf_ptr = ch;
*tty->flip.flag_buf_ptr = 0;
tty->flip.flag_buf_ptr++;
tty->flip.char_buf_ptr++;
tty->flip.count++;
}
tty_flip_buffer_push(tty);
}
开发者ID:BackupTheBerlios,项目名称:tuxap,代码行数:37,代码来源:simserial.c
示例11: receive_chars
static void receive_chars(struct tty_struct *tty, struct pt_regs *regs)
{
unsigned char ch;
static unsigned char seen_esc = 0;
while ( (ch = ia64_ssc(0, 0, 0, 0, SSC_GETCHAR)) ) {
if ( ch == 27 && seen_esc == 0 ) {
seen_esc = 1;
continue;
} else {
if ( seen_esc==1 && ch == 'O' ) {
seen_esc = 2;
continue;
} else if ( seen_esc == 2 ) {
if ( ch == 'P' ) /* F1 */
show_state();
#ifdef CONFIG_MAGIC_SYSRQ
if ( ch == 'S' ) { /* F4 */
do
ch = ia64_ssc(0, 0, 0, 0,
SSC_GETCHAR);
while (!ch);
handle_sysrq(ch, regs, NULL);
}
#endif
seen_esc = 0;
continue;
}
}
seen_esc = 0;
if (tty_insert_flip_char(tty, ch, TTY_NORMAL) == 0)
break;
}
tty_flip_buffer_push(tty);
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:36,代码来源:simserial.c
示例12: try_to_freeze_tasks
static int try_to_freeze_tasks(bool sig_only)
{
struct task_struct *g, *p;
unsigned long end_time;
unsigned int todo;
struct timeval start, end;
u64 elapsed_csecs64;
unsigned int elapsed_csecs;
unsigned int wakeup = 0;
do_gettimeofday(&start);
end_time = jiffies + TIMEOUT;
do {
todo = 0;
read_lock(&tasklist_lock);
do_each_thread(g, p) {
if (frozen(p) || !freezeable(p))
continue;
if (!freeze_task(p, sig_only))
continue;
/*
* Now that we've done set_freeze_flag, don't
* perturb a task in TASK_STOPPED or TASK_TRACED.
* It is "frozen enough". If the task does wake
* up, it will immediately call try_to_freeze.
*
* Because freeze_task() goes through p's
* scheduler lock after setting TIF_FREEZE, it's
* guaranteed that either we see TASK_RUNNING or
* try_to_stop() after schedule() in ptrace/signal
* stop sees TIF_FREEZE.
*/
if (!task_is_stopped_or_traced(p) &&
!freezer_should_skip(p))
todo++;
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
yield(); /* Yield is okay here */
if (todo && has_wake_lock(WAKE_LOCK_SUSPEND)) {
wakeup = 1;
break;
}
if (time_after(jiffies, end_time))
break;
} while (todo);
do_gettimeofday(&end);
elapsed_csecs64 = timeval_to_ns(&end) - timeval_to_ns(&start);
do_div(elapsed_csecs64, NSEC_PER_SEC / 100);
elapsed_csecs = elapsed_csecs64;
if (todo) {
/* This does not unfreeze processes that are already frozen
* (we have slightly ugly calling convention in that respect,
* and caller must call thaw_processes() if something fails),
* but it cleans up leftover PF_FREEZE requests.
*/
printk("\n");
printk(KERN_ERR "Freezing of tasks %s after %d.%02d seconds "
"(%d tasks refusing to freeze):\n",
wakeup ? "aborted" : "failed",
elapsed_csecs / 100, elapsed_csecs % 100, todo);
if(!wakeup)
show_state();
read_lock(&tasklist_lock);
do_each_thread(g, p) {
task_lock(p);
if (freezing(p) && !freezer_should_skip(p) &&
elapsed_csecs > 100)
printk(KERN_ERR " %s\n", p->comm);
cancel_freezing(p);
task_unlock(p);
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
} else {
开发者ID:Jazz-823,项目名称:kernel_ayame,代码行数:78,代码来源:process.c
示例13: handle_sysrq
void handle_sysrq(int key, struct pt_regs *pt_regs,
struct kbd_struct *kbd, struct tty_struct *tty)
{
int orig_log_level = console_loglevel;
if (!key)
return;
console_loglevel = 7;
printk(KERN_INFO "SysRq: ");
switch (key) {
case 'r': /* R -- Reset raw mode */
if (kbd) {
kbd->kbdmode = VC_XLATE;
printk("Keyboard mode set to XLATE\n");
}
break;
#ifdef CONFIG_VT
case 'k': /* K -- SAK */
printk("SAK\n");
if (tty)
do_SAK(tty);
reset_vc(fg_console);
break;
#endif
case 'b': /* B -- boot immediately */
printk("Resetting\n");
machine_restart(NULL);
break;
case 'o': /* O -- power off */
if (sysrq_power_off) {
printk("Power off\n");
sysrq_power_off();
}
break;
case 's': /* S -- emergency sync */
printk("Emergency Sync\n");
emergency_sync_scheduled = EMERG_SYNC;
wakeup_bdflush(0);
break;
case 'u': /* U -- emergency remount R/O */
printk("Emergency Remount R/O\n");
emergency_sync_scheduled = EMERG_REMOUNT;
wakeup_bdflush(0);
break;
case 'p': /* P -- show PC */
printk("Show Regs\n");
if (pt_regs)
show_regs(pt_regs);
break;
case 't': /* T -- show task info */
printk("Show State\n");
show_state();
break;
case 'm': /* M -- show memory info */
printk("Show Memory\n");
show_mem();
break;
case '0' ... '9': /* 0-9 -- set console logging level */
orig_log_level = key - '0';
printk("Log level set to %d\n", orig_log_level);
break;
case 'e': /* E -- terminate all user processes */
printk("Terminate All Tasks\n");
send_sig_all(SIGTERM, 0);
orig_log_level = 8; /* We probably have killed syslogd */
break;
case 'i': /* I -- kill all user processes */
printk("Kill All Tasks\n");
send_sig_all(SIGKILL, 0);
orig_log_level = 8;
break;
case 'l': /* L -- kill all processes including init */
printk("Kill ALL Tasks (even init)\n");
send_sig_all(SIGKILL, 1);
orig_log_level = 8;
break;
default: /* Unknown: help */
if (kbd)
printk("unRaw ");
#ifdef CONFIG_VT
if (tty)
printk("saK ");
#endif
printk("Boot ");
if (sysrq_power_off)
printk("Off ");
printk("Sync Unmount showPc showTasks showMem loglevel0-8 tErm kIll killalL\n");
/* Don't use 'A' as it's handled specially on the Sparc */
}
console_loglevel = orig_log_level;
}
开发者ID:chinnyannieb,项目名称:empeg-hijack,代码行数:93,代码来源:sysrq.c
示例14: receive_chars
static _INLINE_ void receive_chars(struct NIOS_serial *info, struct pt_regs *regs, unsigned short rx)
{
struct tty_struct *tty = info->tty;
unsigned char ch;
np_uart * uart= (np_uart *)(info->port);
/*
* This do { } while() loop will get ALL chars out of Rx FIFO
*/
do {
ch = uart->np_uartrxdata;
if(info->is_cons) {
#ifdef CONFIG_MAGIC_SYSRQ
if(rx & np_uartstatus_brk_mask) {
batten_down_hatches();
return;
} else if (ch == 0x10) { /* ^P */
show_state();
show_mem();
return;
} else if (ch == 0x12) { /* ^R */
hard_reset_now();
return;
#ifdef DEBUG
} else if (ch == 0x02) { /* ^B */
batten_down_hatches();
return;
} else if (ch == 0x01) { /* ^A */
asm("trap 0"); /* Back to monitor */
return; /* (won't be coming back) */
#endif
}
#endif /* CONFIG_MAGIC_SYSRQ */
}
if(!tty)
goto clear_and_exit;
/*
* Make sure that we do not overflow the buffer
*/
if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
queue_task(&tty->flip.tqueue, &tq_timer);
return;
}
if(rx & np_uartstatus_pe_mask) {
*tty->flip.flag_buf_ptr++ = TTY_PARITY;
status_handle(info, rx);
} else if(rx & np_uartstatus_roe_mask) {
*tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
status_handle(info, rx);
} else if(rx & np_uartstatus_fe_mask) {
*tty->flip.flag_buf_ptr++ = TTY_FRAME;
status_handle(info, rx);
} else if(rx & np_uartstatus_brk_mask) {
*tty->flip.flag_buf_ptr++ = TTY_BREAK;
status_handle(info, rx);
} else {
*tty->flip.flag_buf_ptr++ = 0; /* XXX */
}
*tty->flip.char_buf_ptr++ = ch;
tty->flip.count++;
} while((rx = uart->np_uartstatus) & np_uartstatus_rrdy_mask);
queue_task(&tty->flip.tqueue, &tq_timer);
clear_and_exit:
return;
}
开发者ID:ProjectZeroSlackr,项目名称:linux-2.4.32-ipod,代码行数:72,代码来源:NIOSserial.c
示例15: receive_chars
static _INLINE_ void receive_chars(struct bf535_serial *info, struct pt_regs *regs, unsigned short rx)
{
struct tty_struct *tty = info->tty;
unsigned char ch;
int idx = info->hub2;
/*
* This do { } while() loop will get ALL chars out of Rx FIFO
*/
do {
ch = (unsigned char) rx;
if(info->is_cons) {
if (UART_LSR(idx) & UART_LSR_BI){ /* break received */
status_handle(info, UART_LSR(idx));
return;
} else if (ch == 0x10) { /* ^P */
show_state();
show_free_areas();
show_buffers();
/* show_net_buffers(); */
return;
} else if (ch == 0x12) { /* ^R */
machine_restart(NULL);
return;
}
}
if(!tty){
printk("no tty\n");
goto clear_and_exit;
}
/*
* Make sure that we do not overflow the buffer
*/
if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
queue_task(&tty->flip.tqueue, &tq_timer);
return;
}
if(UART_LSR(idx) & UART_LSR_PE) {
*tty->flip.flag_buf_ptr++ = TTY_PARITY;
status_handle(info, UART_LSR(idx));
} else if(UART_LSR(idx) & UART_LSR_OE) {
*tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
status_handle(info, UART_LSR(idx));
} else if(UART_LSR(idx) & UART_LSR_FE) {
*tty->flip.flag_buf_ptr++ = TTY_FRAME;
status_handle(info, UART_LSR(idx));
} else {
*tty->flip.flag_buf_ptr++ = 0; /* XXX */
}
tty->flip.count++;
*tty->flip.char_buf_ptr++ = ch;
ACCESS_PORT_IER(idx) /* change access to port data */
rx = UART_RBR(idx);
} while(UART_LSR(idx) & UART_LSR_DR);
queue_task(&tty->flip.tqueue, &tq_timer);
clear_and_exit:
return;
}
开发者ID:ProjectZeroSlackr,项目名称:linux-2.4.32-ipod,代码行数:66,代码来源:bf535_serial.c
示例16: try_to_freeze_tasks
static int try_to_freeze_tasks(int freeze_user_space)
{
struct task_struct *g, *p;
unsigned long end_time;
unsigned int todo;
struct timeval start, end;
s64 elapsed_csecs64;
unsigned int elapsed_csecs;
do_gettimeofday(&start);
end_time = jiffies + TIMEOUT;
do {
todo = 0;
read_lock(&tasklist_lock);
do_each_thread(g, p) {
if (frozen(p) || !freezeable(p))
continue;
if (p->state == TASK_TRACED && frozen(p->parent)) {
cancel_freezing(p);
continue;
}
if (!freeze_task(p, freeze_user_space))
continue;
if (!freezer_should_skip(p))
todo++;
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
yield(); /* Yield is okay here */
if (time_after(jiffies, end_time))
break;
} while (todo);
do_gettimeofday(&end);
elapsed_csecs64 = timeval_to_ns(&end) - timeval_to_ns(&start);
do_div(elapsed_csecs64, NSEC_PER_SEC / 100);
elapsed_csecs = elapsed_csecs64;
if (todo) {
/* This does not unfreeze processes that are already frozen
* (we have slightly ugly calling convention in that respect,
* and caller must call thaw_processes() if something fails),
* but it cleans up leftover PF_FREEZE requests.
*/
printk("\n");
printk(KERN_ERR "Freezing of tasks failed after %d.%02d seconds "
"(%d tasks refusing to freeze):\n",
elapsed_csecs / 100, elapsed_csecs % 100, todo);
show_state();
read_lock(&tasklist_lock);
do_each_thread(g, p) {
task_lock(p);
if (freezing(p) && !freezer_should_skip(p))
printk(KERN_ERR " %s\n", p->comm);
cancel_freezing(p);
task_unlock(p);
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
} else {
开发者ID:acassis,项目名称:emlinux-ssd1935,代码行数:62,代码来源:process.c
示例17: main
/* main function is a recv-thread, it is used to receive messages *
* sending from the senrver. *
* if it receives a control-message, it will set needsendACK = 1 *
* (to tell send thread that he should send an ACK to the server *
* saying "got it"). *
* if receive a ACK message, it will set haverecvACK = 1, to let *
* the send thread knows that the server had received a temperature *
* message. */
int main()
{
pthread_t sendthread, sendACKthread;
char recvframe[MAX_FRAME_SIZE] = "ABCDEFG";
// char *device = "/dev/ttyAMA0";
// char *device = "/dev/ttyUSB0";
char *device = "/dev/pts/4";
fre = 1;
stop = 0;
haverecvACK = 0;
needsendACK = 0;
pthread_mutex_init(&stop_mutex, NULL);
pthread_mutex_init(&fre_mutex, NULL);
pthread_mutex_init(&have_recv_ack_mutex, NULL);
pthread_mutex_init(&need_send_ack_mutex, NULL);
fd = OpenPort(device);
if(fd < 0) return -1;
pthread_create(&sendthread, NULL, (void *)&SendThreadFun, NULL);
pthread_create(&sendACKthread, NULL, (void *)&SendACKFun, NULL);
while(stop != 1)
{
/*receive a frame and analyse it*/
RecvFrame(fd, recvframe);
int recvmode = AnalyseFrame(recvframe);
if(recvmode == 0)
{
printf("recv: ACK\n");
pthread_mutex_lock(&have_recv_ack_mutex);
haverecvACK = 1;
show_state();
pthread_mutex_unlock(&have_recv_ack_mutex);
}
/* if it receives a frequency-message, it will set needsendACK = 1 *
* (to tell send thread that he should send an ACK to the server *
* saying "got it"). */
if(recvmode == 2 )
{
printf("recv: change frequency %d\n", fre);
char delayAscii[7];
/*extract the number from the recv frame */
memcpy(delayAscii, recvframe + 3, 6);
delayAscii[6] = '\0';
pthread_mutex_lock(&fre_mutex);
fre = atol((const char *) delayAscii);
pthread_mutex_unlock(&fre_mutex);
pthread_mutex_lock(&need_send_ack_mutex);
needsendACK = 1;
show_state();
pthread_mutex_unlock(&need_send_ack_mutex);
}
/* if it receives a stop-message, it will set needsendACK = 1 *
* (to tell send thread that he should send an ACK to the server *
* saying "got it"). */
if(recvmode == 3)
{
printf("recv: STOP!\n");
pthread_mutex_lock(&stop_mutex);
stop = 1;
pthread_mutex_unlock(&stop_mutex);
pthread_mutex_lock(&need_send_ack_mutex);
needsendACK = 1;
show_state();
pthread_mutex_unlock(&need_send_ack_mutex);
}
memset(recvframe, '\0', MAX_FRAME_SIZE);
//usleep(500000);
}
pthread_join(sendthread, NULL);
pthread_join(sendACKthread, NULL);
return 0;
}
开发者ID:ShelmyLin,项目名称:ISIMA_Embedded_Linux_Project,代码行数:88,代码来源:Sensor.c
示例18: try_to_freeze_tasks
static int try_to_freeze_tasks(bool sig_only)
{
struct task_struct *g, *p;
unsigned long end_time;
unsigned int todo;
struct timeval start, end;
u64 elapsed_csecs64;
unsigned int elapsed_csecs;
long wl_timeout;
unsigned int wakeup = 0;
do_gettimeofday(&start);
end_time = jiffies + TIMEOUT;
do {
todo = 0;
read_lock(&tasklist_lock);
do_each_thread(g, p) {
if (frozen(p) || !freezeable(p))
continue;
if (!freeze_task(p, sig_only))
continue;
/*
* Now that we've done set_freeze_flag, don't
* perturb a task in TASK_STOPPED or TASK_TRACED.
* It is "frozen enough". If the task does wake
* up, it will immediately call try_to_freeze.
*/
if (!task_is_stopped_or_traced(p) &&
!freezer_should_skip(p))
todo++;
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
yield(); /* Yield is okay here */
wl_timeout = has_wake_lock_debug(WAKE_LOCK_SUSPEND);
if (todo && wl_timeout) {
printk(KERN_ERR "Suspend prevented for %ld jiffies\n", wl_timeout);
wakeup = 1;
break;
}
if (time_after(jiffies, end_time)) {
printk(KERN_ERR "Suspend attempts timed out\n");
break;
}
} while (todo);
do_gettimeofday(&end);
elapsed_csecs64 = timeval_to_ns(&end) - timeval_to_ns(&start);
do_div(elapsed_csecs64, NSEC_PER_SEC / 100);
elapsed_csecs = elapsed_csecs64;
if (todo) {
/* This does not unfreeze processes that are already frozen
* (we have slightly ugly calling convention in that respect,
* and caller must call thaw_processes() if something fails),
* but it cleans up leftover PF_FREEZE requests.
*/
if(wakeup) {
printk("\n");
printk(KERN_ERR "Freezing of %s aborted\n",
sig_only ? "user space " : "tasks ");
}
else {
printk("\n");
printk(KERN_ERR "Freezing of tasks failed after %d.%02d seconds "
"(%d tasks refusing to freeze):\n",
elapsed_csecs / 100, elapsed_csecs % 100, todo);
show_state();
}
read_lock(&tasklist_lock);
do_each_thread(g, p) {
task_lock(p);
if (freezing(p) && !freezer_should_skip(p))
printk(KERN_ERR " %s\n", p->comm);
cancel_freezing(p);
task_unlock(p);
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
} else {
开发者ID:mali1,项目名称:NST-kernel,代码行数:81,代码来源:process.c
示例19: sysrq_handle_showstate
static void sysrq_handle_showstate(int key, struct tty_struct *tty)
{
show_state();
}
开发者ID:kzlin129,项目名称:tt-gpl,代码行数:4,代码来源:sysrq.c
示例20: try_to_freeze_tasks
static int try_to_freeze_tasks(bool sig_only)
{
struct task_struct *g, *p;
unsigned long end_time;
unsigned int todo;
struct timeval start, end;
u64 elapsed_csecs64;
unsigned int elapsed_csecs;
do_gettimeofday(&start);
end_time = jiffies + TIMEOUT;
while (true) {
todo = 0;
read_lock(&tasklist_lock);
do_each_thread(g, p) {
if (frozen(p) || !freezeable(p))
continue;
if (!freeze_task(p, sig_only))
continue;
/*
* Now that we've done set_freeze_flag, don't
* perturb a task in TASK_STOPPED or TASK_TRACED.
* It is "frozen enough". If the task does wake
* up, it will immediately call try_to_freeze.
*/
if (!task_is_stopped_or_traced(p) &&
!freezer_should_skip(p))
todo++;
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
if (!todo || time_after(jiffies, end_time))
break;
/*
* We need to retry, but first give the freezing tasks some
* time to enter the regrigerator.
*/
msleep(10);
}
do_gettimeofday(&end);
elapsed_csecs64 = timeval_to_ns(&end) - timeval_to_ns(&start);
do_div(elapsed_csecs64, NSEC_PER_SEC / 100);
elapsed_csecs = elapsed_csecs64;
if (todo) {
/* This does not unfreeze processes that are already frozen
* (we have slightly ugly calling convention in that respect,
* and caller must call thaw_processes() if something fails),
* but it cleans up leftover PF_FREEZE requests.
*/
printk("\n");
printk(KERN_ERR "Freezing of tasks failed after %d.%02d seconds "
"(%d tasks refusing to freeze):\n",
elapsed_csecs / 100, elapsed_csecs % 100, todo);
show_state();
read_lock(&tasklist_lock);
do_each_thread(g, p) {
task_lock(p);
if (freezing(p) && !freezer_should_skip(p))
printk(KERN_ERR " %s\n", p->comm);
cancel_freezing(p);
task_unlock(p);
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
} else {
开发者ID:Scorpiion,项目名称:Renux_cross_eglibc,代码行数:69,代码来源:process.c
注:本文中的show_state函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论