本文整理汇总了C++中set_current_state函数的典型用法代码示例。如果您正苦于以下问题:C++ set_current_state函数的具体用法?C++ set_current_state怎么用?C++ set_current_state使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_current_state函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: __rt_mutex_slowlock
/**
* __rt_mutex_slowlock() - Perform the wait-wake-try-to-take loop
* @lock: the rt_mutex to take
* @state: the state the task should block in (TASK_INTERRUPTIBLE
* or TASK_UNINTERRUPTIBLE)
* @timeout: the pre-initialized and started timer, or NULL for none
* @waiter: the pre-initialized rt_mutex_waiter
* @detect_deadlock: passed to task_blocks_on_rt_mutex
*
* lock->wait_lock must be held by the caller.
*/
static int __sched
__rt_mutex_slowlock(struct rt_mutex *lock, int state,
struct hrtimer_sleeper *timeout,
struct rt_mutex_waiter *waiter,
int detect_deadlock)
{
int ret = 0;
for (;;) {
/* Try to acquire the lock: */
if (try_to_take_rt_mutex(lock))
break;
/*
* TASK_INTERRUPTIBLE checks for signals and
* timeout. Ignored otherwise.
*/
if (unlikely(state == TASK_INTERRUPTIBLE)) {
/* Signal pending? */
if (signal_pending(current))
ret = -EINTR;
if (timeout && !timeout->task)
ret = -ETIMEDOUT;
if (ret)
break;
}
/*
* waiter->task is NULL the first time we come here and
* when we have been woken up by the previous owner
* but the lock got stolen by a higher prio task.
*/
if (!waiter->task) {
ret = task_blocks_on_rt_mutex(lock, waiter, current,
detect_deadlock);
/*
* If we got woken up by the owner then start loop
* all over without going into schedule to try
* to get the lock now:
*/
if (unlikely(!waiter->task)) {
/*
* Reset the return value. We might
* have returned with -EDEADLK and the
* owner released the lock while we
* were walking the pi chain.
*/
ret = 0;
continue;
}
if (unlikely(ret))
break;
}
raw_spin_unlock(&lock->wait_lock);
debug_rt_mutex_print_deadlock(waiter);
if (waiter->task)
schedule_rt_mutex(lock);
raw_spin_lock(&lock->wait_lock);
set_current_state(state);
}
return ret;
}
开发者ID:12rafael,项目名称:jellytimekernel,代码行数:78,代码来源:rtmutex.c
示例2: schedule_rt_mutex_test
/*
* Schedule replacement for rtsem_down(). Only called for threads with
* PF_MUTEX_TESTER set.
*
* This allows us to have finegrained control over the event flow.
*
*/
void schedule_rt_mutex_test(struct rt_mutex *mutex)
{
int tid, op, dat;
struct test_thread_data *td;
/* We have to lookup the task */
for (tid = 0; tid < MAX_RT_TEST_THREADS; tid++) {
if (threads[tid] == current)
break;
}
BUG_ON(tid == MAX_RT_TEST_THREADS);
td = &thread_data[tid];
op = td->opcode;
dat = td->opdata;
switch (op) {
case RTTEST_LOCK:
case RTTEST_LOCKINT:
case RTTEST_LOCKNOWAIT:
case RTTEST_LOCKINTNOWAIT:
if (mutex != &mutexes[dat])
break;
if (td->mutexes[dat] != 1)
break;
td->mutexes[dat] = 2;
td->event = atomic_add_return_unchecked(1, &rttest_event);
break;
default:
break;
}
schedule();
switch (op) {
case RTTEST_LOCK:
case RTTEST_LOCKINT:
if (mutex != &mutexes[dat])
return;
if (td->mutexes[dat] != 2)
return;
td->mutexes[dat] = 3;
td->event = atomic_add_return_unchecked(1, &rttest_event);
break;
case RTTEST_LOCKNOWAIT:
case RTTEST_LOCKINTNOWAIT:
if (mutex != &mutexes[dat])
return;
if (td->mutexes[dat] != 2)
return;
td->mutexes[dat] = 1;
td->event = atomic_add_return_unchecked(1, &rttest_event);
return;
default:
return;
}
td->opcode = 0;
for (;;) {
set_current_state(TASK_INTERRUPTIBLE);
if (td->opcode > 0) {
int ret;
set_current_state(TASK_RUNNING);
ret = handle_op(td, 1);
set_current_state(TASK_INTERRUPTIBLE);
if (td->opcode == RTTEST_LOCKCONT)
break;
td->opcode = ret;
}
/* Wait for the next command to be executed */
schedule();
}
/* Restore previous command and data */
td->opcode = op;
td->opdata = dat;
}
开发者ID:novic,项目名称:AniDroid-Hardened-Kernel,代码行数:100,代码来源:rtmutex-tester.c
示例3: zpios_thread_main
static int
zpios_thread_main(void *data)
{
thread_data_t *thr = (thread_data_t *)data;
run_args_t *run_args = thr->run_args;
zpios_time_t t;
dmu_obj_t obj;
__u64 offset;
__u32 chunk_size;
zpios_region_t *region;
char *buf;
unsigned int random_int;
int chunk_noise = run_args->chunk_noise;
int chunk_noise_tmp = 0;
int thread_delay = run_args->thread_delay;
int thread_delay_tmp = 0;
int i, rc = 0;
if (chunk_noise) {
get_random_bytes(&random_int, sizeof (unsigned int));
chunk_noise_tmp = (random_int % (chunk_noise * 2))-chunk_noise;
}
/*
* It's OK to vmem_alloc() this memory because it will be copied
* in to the slab and pointers to the slab copy will be setup in
* the bio when the IO is submitted. This of course is not ideal
* since we want a zero-copy IO path if possible. It would be nice
* to have direct access to those slab entries.
*/
chunk_size = run_args->chunk_size + chunk_noise_tmp;
buf = (char *)vmem_alloc(chunk_size, KM_SLEEP);
ASSERT(buf);
/* Trivial data verification pattern for now. */
if (run_args->flags & DMU_VERIFY)
memset(buf, 'z', chunk_size);
/* Write phase */
mutex_enter(&thr->lock);
thr->stats.wr_time.start = zpios_timespec_now();
mutex_exit(&thr->lock);
while (zpios_get_work_item(run_args, &obj, &offset,
&chunk_size, ®ion, DMU_WRITE)) {
if (thread_delay) {
get_random_bytes(&random_int, sizeof (unsigned int));
thread_delay_tmp = random_int % thread_delay;
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(thread_delay_tmp); /* In jiffies */
}
t.start = zpios_timespec_now();
rc = zpios_dmu_write(run_args, obj.os, obj.obj,
offset, chunk_size, buf);
t.stop = zpios_timespec_now();
t.delta = zpios_timespec_sub(t.stop, t.start);
if (rc) {
zpios_print(run_args->file, "IO error while doing "
"dmu_write(): %d\n", rc);
break;
}
mutex_enter(&thr->lock);
thr->stats.wr_data += chunk_size;
thr->stats.wr_chunks++;
thr->stats.wr_time.delta = zpios_timespec_add(
thr->stats.wr_time.delta, t.delta);
mutex_exit(&thr->lock);
mutex_enter(®ion->lock);
region->stats.wr_data += chunk_size;
region->stats.wr_chunks++;
region->stats.wr_time.delta = zpios_timespec_add(
region->stats.wr_time.delta, t.delta);
/* First time region was accessed */
if (region->init_offset == offset)
region->stats.wr_time.start = t.start;
mutex_exit(®ion->lock);
}
mutex_enter(&run_args->lock_ctl);
run_args->threads_done++;
mutex_exit(&run_args->lock_ctl);
mutex_enter(&thr->lock);
thr->rc = rc;
thr->stats.wr_time.stop = zpios_timespec_now();
mutex_exit(&thr->lock);
wake_up(&run_args->waitq);
set_current_state(TASK_UNINTERRUPTIBLE);
schedule();
/* Check if we should exit */
mutex_enter(&thr->lock);
rc = thr->rc;
//.........这里部分代码省略.........
开发者ID:ColinIanKing,项目名称:zfs,代码行数:101,代码来源:pios.c
示例4: mtd_ioctl
static int mtd_ioctl(struct inode *inode, struct file *file,
u_int cmd, u_long arg)
{
struct mtd_info *mtd = (struct mtd_info *)file->private_data;
int ret = 0;
u_long size;
DEBUG(MTD_DEBUG_LEVEL0, "MTD_ioctl\n");
size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT;
if (cmd & IOC_IN) {
ret = verify_area(VERIFY_READ, (char *)arg, size);
if (ret) return ret;
}
if (cmd & IOC_OUT) {
ret = verify_area(VERIFY_WRITE, (char *)arg, size);
if (ret) return ret;
}
switch (cmd) {
case MEMGETREGIONCOUNT:
if (copy_to_user((int *) arg, &(mtd->numeraseregions), sizeof(int)))
return -EFAULT;
break;
case MEMGETREGIONINFO:
{
struct region_info_user ur;
if (copy_from_user( &ur,
(struct region_info_user *)arg,
sizeof(struct region_info_user))) {
return -EFAULT;
}
if (ur.regionindex >= mtd->numeraseregions)
return -EINVAL;
if (copy_to_user((struct mtd_erase_region_info *) arg,
&(mtd->eraseregions[ur.regionindex]),
sizeof(struct mtd_erase_region_info)))
return -EFAULT;
break;
}
case MEMGETINFO:
if (copy_to_user((struct mtd_info *)arg, mtd,
sizeof(struct mtd_info_user)))
return -EFAULT;
break;
case MEMERASE:
{
struct erase_info *erase=kmalloc(sizeof(struct erase_info),GFP_KERNEL);
if (!erase)
ret = -ENOMEM;
else {
wait_queue_head_t waitq;
DECLARE_WAITQUEUE(wait, current);
init_waitqueue_head(&waitq);
memset (erase,0,sizeof(struct erase_info));
if (copy_from_user(&erase->addr, (u_long *)arg,
2 * sizeof(u_long))) {
kfree(erase);
return -EFAULT;
}
erase->mtd = mtd;
erase->callback = mtd_erase_callback;
erase->priv = (unsigned long)&waitq;
/*
FIXME: Allow INTERRUPTIBLE. Which means
not having the wait_queue head on the stack.
If the wq_head is on the stack, and we
leave because we got interrupted, then the
wq_head is no longer there when the
callback routine tries to wake us up.
*/
ret = mtd->erase(mtd, erase);
if (!ret) {
set_current_state(TASK_UNINTERRUPTIBLE);
add_wait_queue(&waitq, &wait);
if (erase->state != MTD_ERASE_DONE &&
erase->state != MTD_ERASE_FAILED)
schedule();
remove_wait_queue(&waitq, &wait);
set_current_state(TASK_RUNNING);
ret = (erase->state == MTD_ERASE_FAILED)?-EIO:0;
}
kfree(erase);
}
break;
}
case MEMWRITEOOB:
{
struct mtd_oob_buf buf;
//.........这里部分代码省略.........
开发者ID:jameshilliard,项目名称:actiontec_opensrc_mi424wr-rev-ef_fw-20-19-8,代码行数:101,代码来源:mtdchar-compat.c
示例5: bt3c_open
int bt3c_open(bt3c_info_t *info)
{
const struct firmware *firmware;
struct hci_dev *hdev;
int err;
spin_lock_init(&(info->lock));
skb_queue_head_init(&(info->txq));
info->rx_state = RECV_WAIT_PACKET_TYPE;
info->rx_count = 0;
info->rx_skb = NULL;
/* Initialize HCI device */
hdev = hci_alloc_dev();
if (!hdev) {
BT_ERR("Can't allocate HCI device");
return -ENOMEM;
}
info->hdev = hdev;
hdev->type = HCI_PCCARD;
hdev->driver_data = info;
hdev->open = bt3c_hci_open;
hdev->close = bt3c_hci_close;
hdev->flush = bt3c_hci_flush;
hdev->send = bt3c_hci_send_frame;
hdev->destruct = bt3c_hci_destruct;
hdev->ioctl = bt3c_hci_ioctl;
hdev->owner = THIS_MODULE;
/* Load firmware */
err = request_firmware(&firmware, "BT3CPCC.bin", &bt3c_device);
if (err < 0) {
BT_ERR("Firmware request failed");
goto error;
}
err = bt3c_load_firmware(info, firmware->data, firmware->size);
release_firmware(firmware);
if (err < 0) {
BT_ERR("Firmware loading failed");
goto error;
}
/* Timeout before it is safe to send the first HCI packet */
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(HZ);
/* Register HCI device */
err = hci_register_dev(hdev);
if (err < 0) {
BT_ERR("Can't register HCI device");
goto error;
}
return 0;
error:
info->hdev = NULL;
hci_free_dev(hdev);
return err;
}
开发者ID:wxlong,项目名称:Test,代码行数:69,代码来源:bt3c_cs.c
示例6: cpm_uart_wait_until_send
inline void cpm_uart_wait_until_send(struct uart_cpm_port *pinfo)
{
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(pinfo->wait_closing);
}
开发者ID:patrick-ken,项目名称:kernel_808l,代码行数:5,代码来源:cpm_uart_core.c
示例7: usbc_write
/*
* Write endpoint. This routine attempts to break the passed in buffer
* into usb DATA0/1 packet size chunks and send them to the host.
* (The lower-level driver tries to do this too, but easier for us
* to manage things here.)
*
* We are at the mercy of the host here, in that it must send an IN
* token to us to pull this data back, so hopefully some higher level
* protocol is expecting traffic to flow in that direction so the host
* is actually polling us. To guard against hangs, a 5 second timeout
* is used.
*
* This routine takes some care to only report bytes sent that have
* actually made it across the wire. Thus we try to stay in lockstep
* with the completion routine and only have one packet on the xmit
* hardware at a time. Multiple simultaneous writers will get
* "undefined" results.
*
*/
static ssize_t usbc_write( struct file *pFile, const char * pUserBuffer,
size_t stCount, loff_t *pPos )
{
ssize_t retval = 0;
ssize_t stSent = 0;
DECLARE_WAITQUEUE( wait, current );
PRINTK( KERN_DEBUG "%swrite() %d bytes\n", pszMe, stCount );
down( &xmit_sem ); // only one thread onto the hardware at a time
while( stCount != 0 && retval == 0 ) {
int nThisTime = MIN( TX_PACKET_SIZE, stCount );
copy_from_user( tx_buf, pUserBuffer, nThisTime );
sending = nThisTime;
retval = pxa_usb_send( tx_buf, nThisTime, tx_done_callback );
if ( retval < 0 ) {
char * p = what_the_f( retval );
printk( "%sCould not queue xmission. rc=%d - %s\n",
pszMe, retval, p );
sending = 0;
break;
}
/* now have something on the diving board */
add_wait_queue( &wq_write, &wait );
tx_timer.expires = jiffies + ( HZ * 5 );
add_timer( &tx_timer );
while( 1 ) {
set_current_state( TASK_INTERRUPTIBLE );
if ( sending == 0 ) { /* it jumped into the pool */
del_timer( &tx_timer );
retval = last_tx_result;
if ( retval == 0 ) {
stSent += last_tx_size;
pUserBuffer += last_tx_size;
stCount -= last_tx_size;
}
else
printk( "%sxmission error rc=%d - %s\n",
pszMe, retval, what_the_f(retval) );
break;
}
else if ( signal_pending( current ) ) {
del_timer( &tx_timer );
printk( "%ssignal\n", pszMe );
retval = -ERESTARTSYS;
break;
}
schedule();
}
set_current_state( TASK_RUNNING );
remove_wait_queue( &wq_write, &wait );
}
up( &xmit_sem );
if ( 0 == retval )
retval = stSent;
return retval;
}
开发者ID:bticino,项目名称:linux-2.4.19-rmk7-pxa2-btweb,代码行数:80,代码来源:usb-char.c
示例8: mdc800_device_read
/*
* The Device read callback Function
*/
static ssize_t mdc800_device_read (struct file *file, char *buf, size_t len, loff_t *pos)
{
size_t left=len, sts=len; /* single transfer size */
char* ptr=buf;
long timeout;
DECLARE_WAITQUEUE(wait, current);
down (&mdc800->io_lock);
if (mdc800->state == NOT_CONNECTED)
{
up (&mdc800->io_lock);
return -EBUSY;
}
if (mdc800->state == WORKING)
{
warn ("Illegal State \"working\" reached during read ?!");
up (&mdc800->io_lock);
return -EBUSY;
}
if (!mdc800->open)
{
up (&mdc800->io_lock);
return -EBUSY;
}
while (left)
{
if (signal_pending (current))
{
up (&mdc800->io_lock);
return -EINTR;
}
sts=left > (mdc800->out_count-mdc800->out_ptr)?mdc800->out_count-mdc800->out_ptr:left;
if (sts <= 0)
{
/* Too less Data in buffer */
if (mdc800->state == DOWNLOAD)
{
mdc800->out_count=0;
mdc800->out_ptr=0;
/* Download -> Request new bytes */
mdc800->download_urb->dev = mdc800->dev;
if (usb_submit_urb (mdc800->download_urb, GFP_KERNEL))
{
err ("Can't submit download urb (status=%i)",mdc800->download_urb->status);
up (&mdc800->io_lock);
return len-left;
}
add_wait_queue(&mdc800->download_wait, &wait);
timeout = TO_DOWNLOAD_GET_READY*HZ/1000;
while (!mdc800->downloaded && timeout)
{
set_current_state(TASK_UNINTERRUPTIBLE);
timeout = schedule_timeout (timeout);
}
set_current_state(TASK_RUNNING);
remove_wait_queue(&mdc800->download_wait, &wait);
mdc800->downloaded = 0;
if (mdc800->download_urb->status != 0)
{
err ("request download-bytes fails (status=%i)",mdc800->download_urb->status);
up (&mdc800->io_lock);
return len-left;
}
}
else
{
/* No more bytes -> that's an error*/
up (&mdc800->io_lock);
return -EIO;
}
}
else
{
/* Copy Bytes */
if (copy_to_user(ptr, &mdc800->out [mdc800->out_ptr],
sts)) {
up(&mdc800->io_lock);
return -EFAULT;
}
ptr+=sts;
left-=sts;
mdc800->out_ptr+=sts;
}
}
up (&mdc800->io_lock);
return len-left;
}
开发者ID:iPodLinux,项目名称:linux-2.6.7-ipod,代码行数:95,代码来源:mdc800.c
示例9: sync_unplug_thread
static int sync_unplug_thread(void *data)
{
struct hotplug_pcp *hp = data;
wait_for_completion(&hp->unplug_wait);
preempt_disable();
hp->unplug = current;
wait_for_pinned_cpus(hp);
/*
* This thread will synchronize the cpu_down() with threads
* that have pinned the CPU. When the pinned CPU count reaches
* zero, we inform the cpu_down code to continue to the next step.
*/
set_current_state(TASK_UNINTERRUPTIBLE);
preempt_enable();
complete(&hp->synced);
/*
* If all succeeds, the next step will need tasks to wait till
* the CPU is offline before continuing. To do this, the grab_lock
* is set and tasks going into pin_current_cpu() will block on the
* mutex. But we still need to wait for those that are already in
* pinned CPU sections. If the cpu_down() failed, the kthread_should_stop()
* will kick this thread out.
*/
while (!hp->grab_lock && !kthread_should_stop()) {
schedule();
set_current_state(TASK_UNINTERRUPTIBLE);
}
/* Make sure grab_lock is seen before we see a stale completion */
smp_mb();
/*
* Now just before cpu_down() enters stop machine, we need to make
* sure all tasks that are in pinned CPU sections are out, and new
* tasks will now grab the lock, keeping them from entering pinned
* CPU sections.
*/
if (!kthread_should_stop()) {
preempt_disable();
wait_for_pinned_cpus(hp);
preempt_enable();
complete(&hp->synced);
}
set_current_state(TASK_UNINTERRUPTIBLE);
while (!kthread_should_stop()) {
schedule();
set_current_state(TASK_UNINTERRUPTIBLE);
}
set_current_state(TASK_RUNNING);
/*
* Force this thread off this CPU as it's going down and
* we don't want any more work on this CPU.
*/
current->flags &= ~PF_THREAD_BOUND;
do_set_cpus_allowed(current, cpu_present_mask);
migrate_me();
return 0;
}
开发者ID:jpabferreira,项目名称:linux-pcsws,代码行数:63,代码来源:cpu.c
示例10: usbc_read
/*
* Read endpoint. Note that you can issue a read to an
* unconfigured endpoint. Eventually, the host may come along
* and configure underneath this module and data will appear.
*/
static ssize_t usbc_read( struct file *pFile, char *pUserBuffer,
size_t stCount, loff_t *pPos )
{
ssize_t retval;
int flags;
DECLARE_WAITQUEUE( wait, current );
PRINTK( KERN_DEBUG "%sread()\n", pszMe );
local_irq_save( flags );
if ( last_rx_result == 0 ) {
local_irq_restore( flags );
} else { /* an error happended and receiver is paused */
local_irq_restore( flags );
last_rx_result = 0;
kick_start_rx();
}
add_wait_queue( &wq_read, &wait );
while( 1 ) {
ssize_t bytes_avail;
ssize_t bytes_to_end;
set_current_state( TASK_INTERRUPTIBLE );
/* snap ring buf state */
local_irq_save( flags );
bytes_avail = CIRC_CNT( rx_ring.in, rx_ring.out, RBUF_SIZE );
bytes_to_end = CIRC_CNT_TO_END( rx_ring.in, rx_ring.out, RBUF_SIZE );
local_irq_restore( flags );
if ( bytes_avail != 0 ) {
ssize_t bytes_to_move = MIN( stCount, bytes_avail );
retval = 0; // will be bytes transfered
if ( bytes_to_move != 0 ) {
size_t n = MIN( bytes_to_end, bytes_to_move );
if ( copy_to_user( pUserBuffer,
&rx_ring.buf[ rx_ring.out ],
n ) ) {
retval = -EFAULT;
break;
}
bytes_to_move -= n;
retval += n;
// might go 1 char off end, so wrap
rx_ring.out = ( rx_ring.out + n ) & (RBUF_SIZE-1);
if ( copy_to_user( pUserBuffer + n,
&rx_ring.buf[ rx_ring.out ],
bytes_to_move )
) {
retval = -EFAULT;
break;
}
rx_ring.out += bytes_to_move; // cannot wrap
retval += bytes_to_move;
kick_start_rx();
}
break;
}
else if ( last_rx_result ) {
retval = last_rx_result;
break;
}
else if ( pFile->f_flags & O_NONBLOCK ) { // no data, can't sleep
retval = -EAGAIN;
break;
}
else if ( signal_pending( current ) ) { // no data, can sleep, but signal
retval = -ERESTARTSYS;
break;
}
schedule(); // no data, can sleep
}
set_current_state( TASK_RUNNING );
remove_wait_queue( &wq_read, &wait );
if ( retval < 0 )
printk(KERN_DEBUG "%s read error %d - %s\n", pszMe, retval,
what_the_f( retval ) );
return retval;
}
开发者ID:bticino,项目名称:linux-2.4.19-rmk7-pxa2-btweb,代码行数:86,代码来源:usb-char.c
示例11: mmc_queue_thread
static int mmc_queue_thread(void *d)
{
struct mmc_queue *mq = d;
struct request_queue *q = mq->queue;
struct mmc_context_info *cntx = &mq->card->host->context_info;
current->flags |= PF_MEMALLOC;
down(&mq->thread_sem);
do {
struct request *req = NULL;
spin_lock_irq(q->queue_lock);
set_current_state(TASK_INTERRUPTIBLE);
req = blk_fetch_request(q);
mq->asleep = false;
cntx->is_waiting_last_req = false;
cntx->is_new_req = false;
if (!req) {
/*
* Dispatch queue is empty so set flags for
* mmc_request_fn() to wake us up.
*/
if (mq->mqrq_prev->req)
cntx->is_waiting_last_req = true;
else
mq->asleep = true;
}
mq->mqrq_cur->req = req;
spin_unlock_irq(q->queue_lock);
if (req || mq->mqrq_prev->req) {
bool req_is_special = mmc_req_is_special(req);
set_current_state(TASK_RUNNING);
mmc_blk_issue_rq(mq, req);
cond_resched();
if (mq->flags & MMC_QUEUE_NEW_REQUEST) {
mq->flags &= ~MMC_QUEUE_NEW_REQUEST;
continue; /* fetch again */
}
/*
* Current request becomes previous request
* and vice versa.
* In case of special requests, current request
* has been finished. Do not assign it to previous
* request.
*/
if (req_is_special)
mq->mqrq_cur->req = NULL;
mq->mqrq_prev->brq.mrq.data = NULL;
mq->mqrq_prev->req = NULL;
swap(mq->mqrq_prev, mq->mqrq_cur);
} else {
if (kthread_should_stop()) {
set_current_state(TASK_RUNNING);
break;
}
up(&mq->thread_sem);
schedule();
down(&mq->thread_sem);
}
} while (1);
up(&mq->thread_sem);
return 0;
}
开发者ID:forgivemyheart,项目名称:linux,代码行数:69,代码来源:queue.c
示例12: ivtv_stop_v4l2_encode_stream
int ivtv_stop_v4l2_encode_stream(struct ivtv_stream *s, int gop_end)
{
struct ivtv *itv = s->itv;
DECLARE_WAITQUEUE(wait, current);
int cap_type;
int stopmode;
if (s->vdev == NULL)
return -EINVAL;
/* This function assumes that you are allowed to stop the capture
and that we are actually capturing */
IVTV_DEBUG_INFO("Stop Capture\n");
if (s->type == IVTV_DEC_STREAM_TYPE_VOUT)
return 0;
if (atomic_read(&itv->capturing) == 0)
return 0;
switch (s->type) {
case IVTV_ENC_STREAM_TYPE_YUV:
cap_type = 1;
break;
case IVTV_ENC_STREAM_TYPE_PCM:
cap_type = 1;
break;
case IVTV_ENC_STREAM_TYPE_VBI:
cap_type = 1;
break;
case IVTV_ENC_STREAM_TYPE_MPG:
default:
cap_type = 0;
break;
}
/* Stop Capture Mode */
if (s->type == IVTV_ENC_STREAM_TYPE_MPG && gop_end) {
stopmode = 0;
} else {
stopmode = 1;
}
/* end_capture */
/* when: 0 = end of GOP 1 = NOW!, type: 0 = mpeg, subtype: 3 = video+audio */
ivtv_vapi(itv, CX2341X_ENC_STOP_CAPTURE, 3, stopmode, cap_type, s->subtype);
if (!test_bit(IVTV_F_S_PASSTHROUGH, &s->s_flags)) {
if (s->type == IVTV_ENC_STREAM_TYPE_MPG && gop_end) {
/* only run these if we're shutting down the last cap */
unsigned long duration;
unsigned long then = jiffies;
add_wait_queue(&itv->eos_waitq, &wait);
set_current_state(TASK_INTERRUPTIBLE);
/* wait 2s for EOS interrupt */
while (!test_bit(IVTV_F_I_EOS, &itv->i_flags) &&
time_before(jiffies,
then + msecs_to_jiffies(2000))) {
schedule_timeout(msecs_to_jiffies(10));
}
/* To convert jiffies to ms, we must multiply by 1000
* and divide by HZ. To avoid runtime division, we
* convert this to multiplication by 1000/HZ.
* Since integer division truncates, we get the best
* accuracy if we do a rounding calculation of the constant.
* Think of the case where HZ is 1024.
*/
duration = ((1000 + HZ / 2) / HZ) * (jiffies - then);
if (!test_bit(IVTV_F_I_EOS, &itv->i_flags)) {
IVTV_DEBUG_WARN("%s: EOS interrupt not received! stopping anyway.\n", s->name);
IVTV_DEBUG_WARN("%s: waited %lu ms.\n", s->name, duration);
} else {
IVTV_DEBUG_INFO("%s: EOS took %lu ms to occur.\n", s->name, duration);
}
set_current_state(TASK_RUNNING);
remove_wait_queue(&itv->eos_waitq, &wait);
set_bit(IVTV_F_S_STREAMOFF, &s->s_flags);
}
/* Handle any pending interrupts */
ivtv_msleep_timeout(100, 1);
}
atomic_dec(&itv->capturing);
/* Clear capture and no-read bits */
clear_bit(IVTV_F_S_STREAMING, &s->s_flags);
if (s->type == IVTV_ENC_STREAM_TYPE_VBI)
ivtv_set_irq_mask(itv, IVTV_IRQ_ENC_VBI_CAP);
if (atomic_read(&itv->capturing) > 0) {
return 0;
}
//.........这里部分代码省略.........
开发者ID:karelh,项目名称:liquidware_beagleboard_linux,代码行数:101,代码来源:ivtv-streams.c
示例13: splat_atomic_work
static void
splat_atomic_work(void *priv)
{
atomic_priv_t *ap;
atomic_op_t op;
int i;
ap = (atomic_priv_t *)priv;
ASSERT(ap->ap_magic == SPLAT_ATOMIC_TEST_MAGIC);
mutex_lock(&ap->ap_lock);
op = ap->ap_op;
wake_up(&ap->ap_waitq);
mutex_unlock(&ap->ap_lock);
splat_vprint(ap->ap_file, SPLAT_ATOMIC_TEST1_NAME,
"Thread %d successfully started: %lu/%lu\n", op,
(long unsigned)ap->ap_atomic,
(long unsigned)ap->ap_atomic_exited);
for (i = 0; i < SPLAT_ATOMIC_INIT_VALUE / 10; i++) {
/* Periodically sleep to mix up the ordering */
if ((i % (SPLAT_ATOMIC_INIT_VALUE / 100)) == 0) {
splat_vprint(ap->ap_file, SPLAT_ATOMIC_TEST1_NAME,
"Thread %d sleeping: %lu/%lu\n", op,
(long unsigned)ap->ap_atomic,
(long unsigned)ap->ap_atomic_exited);
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(HZ / 100);
}
switch (op) {
case SPLAT_ATOMIC_INC_64:
atomic_inc_64(&ap->ap_atomic);
break;
case SPLAT_ATOMIC_DEC_64:
atomic_dec_64(&ap->ap_atomic);
break;
case SPLAT_ATOMIC_ADD_64:
atomic_add_64(&ap->ap_atomic, 3);
break;
case SPLAT_ATOMIC_SUB_64:
atomic_sub_64(&ap->ap_atomic, 3);
break;
case SPLAT_ATOMIC_ADD_64_NV:
atomic_add_64_nv(&ap->ap_atomic, 5);
break;
case SPLAT_ATOMIC_SUB_64_NV:
atomic_sub_64_nv(&ap->ap_atomic, 5);
break;
default:
PANIC("Undefined op %d\n", op);
}
}
atomic_inc_64(&ap->ap_atomic_exited);
splat_vprint(ap->ap_file, SPLAT_ATOMIC_TEST1_NAME,
"Thread %d successfully exited: %lu/%lu\n", op,
(long unsigned)ap->ap_atomic,
(long unsigned)ap->ap_atomic_exited);
wake_up(&ap->ap_waitq);
thread_exit();
}
开发者ID:clopez,项目名称:spl-dkms,代码行数:66,代码来源:splat-atomic.c
示例14: mdc800_device_write
/*
* The Device write callback Function
* If a 8Byte Command is received, it will be send to the camera.
* After this the driver initiates the request for the answer or
* just waits until the camera becomes ready.
*/
static ssize_t mdc800_device_write (struct file *file, const char *buf, size_t len, loff_t *pos)
{
size_t i=0;
DECLARE_WAITQUEUE(wait, current);
down (&mdc800->io_lock);
if (mdc800->state != READY)
{
up (&mdc800->io_lock);
return -EBUSY;
}
if (!mdc800->open )
{
up (&mdc800->io_lock);
return -EBUSY;
}
while (i<len)
{
unsigned char c;
if (signal_pending (current))
{
up (&mdc800->io_lock);
return -EINTR;
}
if(get_user(c, buf+i))
{
up(&mdc800->io_lock);
return -EFAULT;
}
/* check for command start */
if (c == 0x55)
{
mdc800->in_count=0;
mdc800->out_count=0;
mdc800->out_ptr=0;
mdc800->download_left=0;
}
/* save command byte */
if (mdc800->in_count < 8)
{
mdc800->in[mdc800->in_count] = c;
mdc800->in_count++;
}
else
{
up (&mdc800->io_lock);
return -EIO;
}
/* Command Buffer full ? -> send it to camera */
if (mdc800->in_count == 8)
{
int answersize;
long timeout;
if (mdc800_usb_waitForIRQ (0,TO_GET_READY))
{
err ("Camera didn't get ready.\n");
up (&mdc800->io_lock);
return -EIO;
}
answersize=mdc800_getAnswerSize (mdc800->in[1]);
mdc800->state=WORKING;
memcpy (mdc800->write_urb->transfer_buffer, mdc800->in,8);
mdc800->write_urb->dev = mdc800->dev;
if (usb_submit_urb (mdc800->write_urb, GFP_KERNEL))
{
err ("submitting write urb fails (status=%i)", mdc800->write_urb->status);
up (&mdc800->io_lock);
return -EIO;
}
add_wait_queue(&mdc800->write_wait, &wait);
timeout = TO_WRITE_GET_READY*HZ/1000;
while (!mdc800->written && timeout)
{
set_current_state(TASK_UNINTERRUPTIBLE);
timeout = schedule_timeout (timeout);
}
set_current_state(TASK_RUNNING);
remove_wait_queue(&mdc800->write_wait, &wait);
mdc800->written = 0;
if (mdc800->state == WORKING)
{
usb_unlink_urb (mdc800->write_urb);
up (&mdc800->io_lock);
return -EIO;
}
//.........这里部分代码省略.........
开发者ID:iPodLinux,项目名称:linux-2.6.7-ipod,代码行数:101,代码来源:mdc800.c
示例15: vc_watchdog_thread_func
static int
vc_watchdog_thread_func(void *v)
{
while (1) {
long rc;
unsigned long msg = WDOG_PING_MSG;
VCHIQ_ELEMENT_T elem = {
.data = (void *)&msg,
.size = sizeof(msg)
};
int time_remaining =
msecs_to_jiffies(WATCHDOG_PING_RATE_MS);
LOG_DBG("%s: waiting on disable blocker...", __func__);
if (wait_for_completion_interruptible(
&vc_wdog_state->wdog_disable_blocker) != 0) {
flush_signals(current);
continue;
}
LOG_DBG("%s: Waiting for VC to be awake...", __func__);
/* Ensure we only ping videocore when it's awake. Call use
* service in a mode which will not initiate a wakeup */
vchiq_use_service_no_resume(vc_wdog_state->service_handle);
if (!atomic_read(&vc_wdog_state->wdog_enabled)) {
vchiq_release_service(vc_wdog_state->service_handle);
LOG_DBG("%s: VC watchdog disabled", __func__);
continue;
}
if (mutex_lock_interruptible(&vc_wdog_state->wdog_ping_mutex)
!= 0) {
vchiq_release_service(vc_wdog_state->service_handle);
LOG_DBG("%s: Interrupted waiting for ping", __func__);
continue;
}
LOG_DBG("%s: Pinging videocore", __func__);
/* ping vc... */
vchiq_queue_message(vc_wdog_state->service_handle, &elem, 1);
LOG_DBG("%s: Waiting for ping response", __func__);
/* ...and wait for the response with a timeout */
rc = wait_for_completion_interruptible_timeout(
&vc_wdog_state->wdog_ping_response,
msecs_to_jiffies(VC_PING_RESPONSE_TIMEOUT_MS));
if (rc == 0) {
/* Timed out... BANG! */
vc_wdog_state->failed_pings++;
LOG_ERR("%s VideoCore Watchdog timed out!! (%d)",
__func__, vc_wdog_state->failed_pings);
if (vc_wdog_state->failed_pings >=
WATCHDOG_NO_RESPONSE_COUNT)
BUG();
} else if (rc < 0)
LOG_ERR("%s: Interrupted waiting for ping", __func__);
else {
LOG_DBG("%s: Ping response received", __func__);
vc_wdog_state->failed_pings = 0;
}
mutex_unlock(&vc_wdog_state->wdog_ping_mutex);
vchiq_release_service(vc_wdog_state->service_handle);
LOG_DBG("%s: waiting before pinging again...", __func__);
/* delay before running again */
do {
set_current_state(TASK_INTERRUPTIBLE);
time_remaining = schedule_timeout(time_remaining);
if (time_remaining) {
LOG_ERR("%s interrupted", __func__);
flush_signals(current);
}
} while (time_remaining > 0);
}
return 0;
}
static void vc_watchdog_connected_init(void)
{
int ret = 0;
VCHIQ_SERVICE_PARAMS_T vchiq_params = {
.fourcc = VCHIQ_MAKE_FOURCC('W', 'D', 'O', 'G'),
.callback = vc_watchdog_vchiq_callback,
.version = VC_WDOG_VERSION,
.version_min = VC_WDOG_VERSION_MIN
};
LOG_INFO("%s: start", __func__);
/* Initialize and create a VCHIQ connection */
ret = vchiq_initialise(&vc_wdog_state->initialise_instance);
if (ret != 0) {
LOG_ERR("%s: failed to initialise VCHIQ instance (ret=%d)",
__func__, ret);
ret = -EIO;
//.........这里部分代码省略.........
开发者ID:emreharbutoglu,项目名称:i9105Sammy,代码行数:101,代码来源:vc_watchdog.c
示例16: setup_netjet_s
int __init
setup_netjet_s(struct IsdnCard *card)
{
int bytecnt;
struct IsdnCardState *cs = card->cs;
char tmp[64];
long flags;
#ifdef __BIG_ENDIAN
#error "not running on big endian machines now"
#endif
strcpy(tmp, NETjet_S_revision);
printk(KERN_INFO "HiSax: Traverse Tech. NETjet-S driver Rev. %s\n", HiSax_getrev(tmp));
if (cs->typ != ISDN_CTYPE_NETJET_S)
return(0);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
#if CONFIG_PCI
for ( ;; )
{
if (!pci_present()) {
printk(KERN_ERR "Netjet: no PCI bus present\n");
return(0);
}
if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET,
PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) {
if (pci_enable_device(dev_netjet))
return(0);
pci_set_master(dev_netjet);
cs->irq = dev_netjet->irq;
if (!cs->irq) {
printk(KERN_WARNING "NETjet-S: No IRQ for PCI card found\n");
return(0);
}
cs->hw.njet.base = pci_resource_start(dev_netjet, 0);
if (!cs->hw.njet.base) {
printk(KERN_WARNING "NETjet-S: No IO-Adr for PCI card found\n");
return(0);
}
/* 2001/10/04 Christoph Ersfeld, Formula-n Europe AG www.formula-n.com */
if ((dev_netjet->subsystem_vendor == 0x55) &&
(dev_netjet->subsystem_device == 0x02)) {
printk(KERN_WARNING "Netjet: You tried to load this driver with an incompatible TigerJet-card\n");
printk(KERN_WARNING "Use type=41 for Formula-n enter:now ISDN PCI and compatible\n");
return(0);
}
/* end new code */
} else {
printk(KERN_WARNING "NETjet-S: No PCI card found\n");
return(0);
}
cs->hw.njet.auxa = cs->hw.njet.base + NETJET_AUXDATA;
cs->hw.njet.isac = cs->hw.njet.base | NETJET_ISAC_OFF;
save_flags(flags);
sti();
cs->hw.njet.ctrl_reg = 0xff; /* Reset On */
byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout((10*HZ)/1000); /* Timeout 10ms */
cs->hw.njet.ctrl_reg = 0x00; /* Reset Off and status read clear */
byteout(cs->hw.njet.base + NETJET_CTRL, cs->hw.njet.ctrl_reg);
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout((10*HZ)/1000); /* Timeout 10ms */
restore_flags(flags);
cs->hw.njet.auxd = 0xC0;
cs->hw.njet.dmactrl = 0;
byteout(cs->hw.njet.base + NETJET_AUXCTRL, ~NETJET_ISACIRQ);
byteout(cs->hw.njet.base + NETJET_IRQMASK1, NETJET_ISACIRQ);
byteout(cs->hw.njet.auxa, cs->hw.njet.auxd);
switch ( ( ( NETjet_ReadIC( cs, ISAC_RBCH ) >> 5 ) & 3 ) )
{
case 0 :
break;
case 3 :
printk( KERN_WARNING "NETjet-S: NETspider-U PCI card found\n" );
continue;
default :
printk( KERN_WARNING "NETjet-S: No PCI card found\n" );
return 0;
}
break;
}
#else
printk(KERN_WARNING "NETjet-S: NO_PCI_BIOS\n");
printk(KERN_WARNING "NETjet-S: unable to config NETJET-S PCI\n");
return (0);
//.........这里部分代码省略.........
开发者ID:ProjectZeroSlackr,项目名称:linux-2.4.32-ipod,代码行数:101,代码来源:nj_s.c
示例17: timod_getmsg
int timod_getmsg(unsigned int fd, char *ctl_buf, int ctl_maxlen, s32 *ctl_len,
char *data_buf, int data_maxlen, s32 *data_len, int *flags_p)
{
int error;
int oldflags;
struct file *filp;
struct inode *ino;
struct sol_socket_struct *sock;
struct T_unitdata_ind udi;
mm_segment_t old_fs = get_fs();
long args[6];
char *tmpbuf;
int tmplen;
int (*sys_socketcall)(int, unsigned long *) =
(int (*)(int, unsigned long *))SYS(socketcall);
int (*sys_recvfrom)(int, void *, size_t, unsigned, struct sockaddr *, int *);
SOLD("entry");
SOLDD(("%u %p %d %p %p %d %p %d\n", fd, ctl_buf, ctl_maxlen, ctl_len, data_buf, data_maxlen, data_len, *flags_p));
filp = current->files->fd[fd];
ino = filp->f_dentry->d_inode;
sock = (struct sol_socket_struct *)filp->private_data;
SOLDD(("%p %p\n", sock->pfirst, sock->pfirst ? sock->pfirst->next : NULL));
if ( ctl_maxlen > 0 && !sock->pfirst && ino->u.socket_i.type == SOCK_STREAM
&& sock->state == TS_IDLE) {
SOLD("calling LISTEN");
args[0] = fd;
args[1] = -1;
set_fs(KERNEL_DS);
sys_socketcall(SYS_LISTEN, args);
set_fs(old_fs);
SOLD("LISTEN done");
}
if (!(filp->f_flags & O_NONBLOCK)) {
poll_table wait_table, *wait;
poll_initwait(&wait_table);
wait = &wait_table;
for(;;) {
SOLD("loop");
set_current_state(TASK_INTERRUPTIBLE);
/* ! ( l<0 || ( l>=0 && ( ! pfirst || (flags == HIPRI && pri != HIPRI) ) ) ) */
/* ( ! l<0 && ! ( l>=0 && ( ! pfirst || (flags == HIPRI && pri != HIPRI) ) ) ) */
/* ( l>=0 && ( ! l>=0 || ! ( ! pfirst || (flags == HIPRI && pri != HIPRI) ) ) ) */
/* ( l>=0 && ( l<0 || ( pfirst && ! (flags == HIPRI && pri != HIPRI) ) ) ) */
/* ( l>=0 && ( l<0 || ( pfirst && (flags != HIPRI || pri == HIPRI) ) ) ) */
/* ( l>=0 && ( pfirst && (flags != HIPRI || pri == HIPRI) ) ) */
if (ctl_maxlen >= 0 && sock->pfirst && (*flags_p != MSG_HIPRI || sock->pfirst->pri == MSG_HIPRI))
break;
SOLD("cond 1 passed");
if (
#if 1
*flags_p != MSG_HIPRI &&
#endif
((filp->f_op->poll(filp, wait) & POLLIN) ||
(filp->f_op->poll(filp, NULL) & POLLIN) ||
signal_pending(current))
) {
break;
}
if( *flags_p == MSG_HIPRI ) {
SOLD("avoiding lockup");
break ;
}
if(wait_table.error) {
SOLD("wait-table error");
poll_freewait(&wait_table);
return wait_table.error;
}
SOLD("scheduling");
schedule();
}
SOLD("loop done");
current->state = TASK_RUNNING;
poll_freewait(&wait_table);
if (signal_pending(current)) {
SOLD("signal pending");
return -EINTR;
}
}
if (ctl_maxlen >= 0 && sock->pfirst) {
struct T_primsg *it = sock->pfirst;
int l = min_t(int, ctl_maxlen, it->length);
SCHECK_MAGIC((char*)((u64)(((char *)&it->type)+sock->offset+it->length+7)&~7),MKCTL_MAGIC);
SOLD("purting ctl data");
if(copy_to_user(ctl_buf,
(char*)&it->type + sock->offset, l))
return -EFAULT;
SOLD("pur it");
if(put_user(l, ctl_len))
return -EFAULT;
SOLD("set ctl_len");
*flags_p = it->pri;
it->length -= l;
if (it->length) {
SOLD("more ctl");
sock->offset += l;
return MORECTL;
} else {
SOLD("removing message");
//.........这里部分代码省略.........
开发者ID:fgeraci,项目名称:cs518-sched,代码行数:101,代码来源:timod.c
|
请发表评论