本文整理汇总了C++中set_freezable函数的典型用法代码示例。如果您正苦于以下问题:C++ set_freezable函数的具体用法?C++ set_freezable怎么用?C++ set_freezable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_freezable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kthread_worker_fn
/**
* kthread_worker_fn - kthread function to process kthread_worker
* @worker_ptr: pointer to initialized kthread_worker
*
* This function can be used as @threadfn to kthread_create() or
* kthread_run() with @worker_ptr argument pointing to an initialized
* kthread_worker. The started kthread will process work_list until
* the it is stopped with kthread_stop(). A kthread can also call
* this function directly after extra initialization.
*
* Different kthreads can be used for the same kthread_worker as long
* as there's only one kthread attached to it at any given time. A
* kthread_worker without an attached kthread simply collects queued
* kthread_works.
*/
int kthread_worker_fn(void *worker_ptr)
{
struct kthread_worker *worker = worker_ptr;
struct kthread_work *work;
WARN_ON(worker->task);
worker->task = current;
set_freezable();
repeat:
set_current_state(TASK_INTERRUPTIBLE); /* mb paired w/ kthread_stop */
if (kthread_should_stop()) {
__set_current_state(TASK_RUNNING);
spin_lock_irq(&worker->lock);
worker->task = NULL;
spin_unlock_irq(&worker->lock);
return 0;
}
work = NULL;
spin_lock_irq(&worker->lock);
if (!list_empty(&worker->work_list)) {
work = list_first_entry(&worker->work_list,
struct kthread_work, node);
list_del_init(&work->node);
}
示例2: flush_delta_work
static int flush_delta_work(void *data)
{
struct sb *sb = data;
int err;
set_freezable();
/*
* Our parent may run at a different priority, just set us to normal
*/
set_user_nice(current, 0);
while (!kthread_freezable_should_stop(NULL)) {
if (test_bit(TUX3_COMMIT_PENDING_BIT, &sb->backend_state)) {
clear_bit(TUX3_COMMIT_PENDING_BIT, &sb->backend_state);
err = flush_delta(sb);
/* FIXME: error handling */
}
set_current_state(TASK_INTERRUPTIBLE);
if (!test_bit(TUX3_COMMIT_PENDING_BIT, &sb->backend_state) &&
!kthread_should_stop())
schedule();
__set_current_state(TASK_RUNNING);
}
return 0;
}
示例3: test_func
static int test_func(void *data)
{
struct test_thread_data *td = data;
int ret;
current->flags |= PF_MUTEX_TESTER;
set_freezable();
allow_signal(SIGHUP);
for(;;) {
set_current_state(TASK_INTERRUPTIBLE);
if (td->opcode > 0) {
set_current_state(TASK_RUNNING);
ret = handle_op(td, 0);
set_current_state(TASK_INTERRUPTIBLE);
td->opcode = ret;
}
/* Wait for the next command to be executed */
schedule();
try_to_freeze();
if (signal_pending(current))
flush_signals(current);
if(kthread_should_stop())
break;
}
return 0;
}
示例4: balloon
static int balloon(void *_vballoon)
{
struct virtio_balloon *vb = _vballoon;
set_freezable();
while (!kthread_should_stop()) {
s64 diff;
try_to_freeze();
wait_event_interruptible(vb->config_change,
(diff = towards_target(vb)) != 0
|| vb->need_stats_update
|| kthread_should_stop()
|| freezing(current));
if (vb->need_stats_update)
stats_handle_request(vb);
if (diff > 0)
fill_balloon(vb, diff);
else if (diff < 0)
leak_balloon(vb, -diff);
update_balloon_size(vb);
/*
* For large balloon changes, we could spend a lot of time
* and always have work to do. Be nice if preempt disabled.
*/
cond_resched();
}
return 0;
}
示例5: kclient_thread_finish
static int
kclient_thread_finish(void *data)
{
int nattempt = atomic_read(&kclient_connect_nattempt);
uint64_t time_max = (uint64_t)get_seconds() + KCLIENT_WAIT_MAX;
set_freezable();
do {
long timeout = KCLIENT_WAIT_INTVL;
int nerror = atomic_read(&kclient_connect_nerror);
int ncomplete = atomic_read(&kclient_connect_ncomplete);
if (ncomplete + nerror == nattempt) {
break;
}
wait_event_freezable_timeout(kclient_finish_wq,
kthread_should_stop(),
timeout);
if ((uint64_t)get_seconds() > time_max) {
SS_ERR("%s exceeded maximum wait time of %d seconds\n",
"kclient_thread_finish", KCLIENT_WAIT_MAX);
break;
}
} while (!kthread_should_stop());
kclient_release_sockets();
kclient_finish_task = NULL;
return 0;
}
示例6: rts51x_scan_thread
static int rts51x_scan_thread(void *__chip)
{
struct rts51x_chip *chip = (struct rts51x_chip *)__chip;
printk(KERN_DEBUG
"rts51x: device found at %d\n", chip->usb->pusb_dev->devnum);
set_freezable();
if (delay_use > 0) {
printk(KERN_DEBUG "rts51x: waiting for device "
"to settle before scanning\n");
wait_event_freezable_timeout(chip->usb->delay_wait,
test_bit(FLIDX_DONT_SCAN,
&chip->usb->dflags),
delay_use * HZ);
}
if (!test_bit(FLIDX_DONT_SCAN, &chip->usb->dflags)) {
scsi_scan_host(rts51x_to_host(chip));
printk(KERN_DEBUG "rts51x: device scan complete\n");
}
complete_and_exit(&chip->usb->scanning_done, 0);
}
示例7: nfs41_callback_svc
/*
* The callback service for NFSv4.1 callbacks
*/
static int
nfs41_callback_svc(void *vrqstp)
{
struct svc_rqst *rqstp = vrqstp;
struct svc_serv *serv = rqstp->rq_server;
struct rpc_rqst *req;
int error;
DEFINE_WAIT(wq);
set_freezable();
while (!kthread_freezable_should_stop(NULL)) {
if (signal_pending(current))
flush_signals(current);
prepare_to_wait(&serv->sv_cb_waitq, &wq, TASK_INTERRUPTIBLE);
spin_lock_bh(&serv->sv_cb_lock);
if (!list_empty(&serv->sv_cb_list)) {
req = list_first_entry(&serv->sv_cb_list,
struct rpc_rqst, rq_bc_list);
list_del(&req->rq_bc_list);
spin_unlock_bh(&serv->sv_cb_lock);
finish_wait(&serv->sv_cb_waitq, &wq);
dprintk("Invoking bc_svc_process()\n");
error = bc_svc_process(serv, req, rqstp);
dprintk("bc_svc_process() returned w/ error code= %d\n",
error);
} else {
示例8: tfw_bmb_worker
static int
tfw_bmb_worker(void *data)
{
int tn = (int)(long)data;
TfwBmbTask *task = &bmb_task[tn];
int attempt, send, k, i;
unsigned long time_max;
fuzz_init(&task->ctx, true);
for (k = 0; k < niters; k++) {
task->conn_attempt = 0;
atomic_set(&task->conn_compl, 0);
atomic_set(&task->conn_error, 0);
atomic_set(&task->conn_rd_tail, 0);
init_waitqueue_head(&task->conn_wq);
for (i = 0; i < nconns; i++)
tfw_bmb_connect(tn, i);
set_freezable();
time_max = jiffies + 60 * HZ;
attempt = task->conn_attempt;
do {
#define COND() (atomic_read(&task->conn_compl) > 0 || \
atomic_read(&task->conn_error) == attempt)
wait_event_freezable_timeout(task->conn_wq, COND(), HZ);
#undef COND
if (atomic_read(&task->conn_compl) > 0)
break;
if (atomic_read(&task->conn_error) == attempt)
goto release_sockets;
if (jiffies > time_max) {
TFW_ERR("worker exceeded maximum wait time\n");
goto release_sockets;
}
} while (!kthread_should_stop());
for (send = 0; send < nconns * nmessages; ) {
int tail = atomic_read(&task->conn_rd_tail);
for (i = 0; i < tail; i++){
tfw_bmb_msg_send(tn, task->conn_rd[i]);
send++;
}
}
release_sockets:
atomic_add(attempt, &bmb_conn_attempt);
atomic_add(atomic_read(&task->conn_compl), &bmb_conn_compl);
atomic_add(atomic_read(&task->conn_error), &bmb_conn_error);
tfw_bmb_release_sockets(tn);
}
task->task_struct = NULL;
atomic_dec(&bmb_threads);
wake_up(&bmb_task_wq);
return 0;
}
示例9: pvr2_dvb_feed_func
static int pvr2_dvb_feed_func(struct pvr2_dvb_adapter *adap)
{
int ret;
unsigned int count;
struct pvr2_buffer *bp;
struct pvr2_stream *stream;
pvr2_trace(PVR2_TRACE_DVB_FEED, "dvb feed thread started");
set_freezable();
stream = adap->channel.stream->stream;
for (;;) {
if (kthread_should_stop()) break;
/* Not sure about this... */
try_to_freeze();
bp = pvr2_stream_get_ready_buffer(stream);
if (bp != NULL) {
count = pvr2_buffer_get_count(bp);
if (count) {
dvb_dmx_swfilter(
&adap->demux,
adap->buffer_storage[
pvr2_buffer_get_id(bp)],
count);
} else {
ret = pvr2_buffer_get_status(bp);
if (ret < 0) break;
}
ret = pvr2_buffer_queue(bp);
if (ret < 0) break;
/* Since we know we did something to a buffer,
just go back and try again. No point in
blocking unless we really ran out of
buffers to process. */
continue;
}
/* Wait until more buffers become available or we're
told not to wait any longer. */
ret = wait_event_interruptible(
adap->buffer_wait_data,
(pvr2_stream_get_ready_count(stream) > 0) ||
kthread_should_stop());
if (ret < 0) break;
}
/* If we get here and ret is < 0, then an error has occurred.
Probably would be a good idea to communicate that to DVB core... */
pvr2_trace(PVR2_TRACE_DVB_FEED, "dvb feed thread stopped");
return 0;
}
示例10: pvr2_dvb_feed_func
static int pvr2_dvb_feed_func(struct pvr2_dvb_adapter *adap)
{
int ret;
unsigned int count;
struct pvr2_buffer *bp;
struct pvr2_stream *stream;
pvr2_trace(PVR2_TRACE_DVB_FEED, "dvb feed thread started");
set_freezable();
stream = adap->channel.stream->stream;
for (;;) {
if (kthread_should_stop()) break;
/* */
try_to_freeze();
bp = pvr2_stream_get_ready_buffer(stream);
if (bp != NULL) {
count = pvr2_buffer_get_count(bp);
if (count) {
dvb_dmx_swfilter(
&adap->demux,
adap->buffer_storage[
pvr2_buffer_get_id(bp)],
count);
} else {
ret = pvr2_buffer_get_status(bp);
if (ret < 0) break;
}
ret = pvr2_buffer_queue(bp);
if (ret < 0) break;
/*
*/
continue;
}
/*
*/
ret = wait_event_interruptible(
adap->buffer_wait_data,
(pvr2_stream_get_ready_count(stream) > 0) ||
kthread_should_stop());
if (ret < 0) break;
}
/*
*/
pvr2_trace(PVR2_TRACE_DVB_FEED, "dvb feed thread stopped");
return 0;
}
示例11: lockd
/*
* This is the lockd kernel thread
*/
static int
lockd(void *vrqstp)
{
int err = 0;
struct svc_rqst *rqstp = vrqstp;
struct net *net = &init_net;
struct lockd_net *ln = net_generic(net, lockd_net_id);
/* try_to_freeze() is called from svc_recv() */
set_freezable();
/* Allow SIGKILL to tell lockd to drop all of its locks */
allow_signal(SIGKILL);
dprintk("NFS locking service started (ver " LOCKD_VERSION ").\n");
/*
* The main request loop. We don't terminate until the last
* NFS mount or NFS daemon has gone away.
*/
while (!kthread_should_stop()) {
long timeout = MAX_SCHEDULE_TIMEOUT;
RPC_IFDEBUG(char buf[RPC_MAX_ADDRBUFLEN]);
/* update sv_maxconn if it has changed */
rqstp->rq_server->sv_maxconn = nlm_max_connections;
if (signalled()) {
flush_signals(current);
restart_grace();
continue;
}
timeout = nlmsvc_retry_blocked();
/*
* Find a socket with data available and call its
* recvfrom routine.
*/
err = svc_recv(rqstp, timeout);
if (err == -EAGAIN || err == -EINTR)
continue;
dprintk("lockd: request from %s\n",
svc_print_addr(rqstp, buf, sizeof(buf)));
svc_process(rqstp);
}
flush_signals(current);
if (nlmsvc_ops)
nlmsvc_invalidate_all();
nlm_shutdown_hosts();
cancel_delayed_work_sync(&ln->grace_period_end);
locks_end_grace(&ln->lockd_manager);
return 0;
}
示例12: tps65090_charger_poll_task
static int tps65090_charger_poll_task(void *data)
{
set_freezable();
while (!kthread_should_stop()) {
schedule_timeout_interruptible(POLL_INTERVAL);
try_to_freeze();
tps65090_charger_isr(-1, data);
}
return 0;
}
示例13: kopald
static int kopald(void *unused)
{
set_freezable();
do {
try_to_freeze();
opal_poll_events(NULL);
msleep_interruptible(opal_heartbeat);
} while (!kthread_should_stop());
return 0;
}
示例14: update_counter_thread
int update_counter_thread(void *data)
{
TZ_RESULT ret;
KREE_SESSION_HANDLE icnt_session;
uint32_t result;
uint32_t a, b, rate;
uint32_t nsec = THREAD_COUNT_FREQ;
ret = KREE_CreateSession(TZ_TA_ICNT_UUID, &icnt_session);
if (ret != TZ_RESULT_SUCCESS)
{
printk("CreateSession error %d\n", ret);
return 1;
}
result = TEECK_Icnt_Rate(icnt_session, &rate);
if (result == TZ_RESULT_SUCCESS)
{
//printk("(yjdbg) rate: %d\n", rate);
nsec = (0xffffffff / rate);
nsec -= 600;
//printk("(yjdbg) rate: %d\n", nsec);
}
set_freezable();
for (;;) {
if (kthread_should_stop())
break;
if (try_to_freeze())
continue;
result = TEECK_Icnt_Counter(icnt_session, &a, &b);
if (result == TZ_RESULT_SUCCESS)
{
//printk("(yjdbg) tz_test TZCMD_ICNT_COUNT: 0x%x, 0x%x\n", a, b);
}
schedule_timeout_interruptible(HZ * nsec);
}
ret = KREE_CloseSession(icnt_session);
if (ret != TZ_RESULT_SUCCESS)
{
printk("CloseSession error %d\n", ret);
return 1;
}
return 0;
}
示例15: videobuf_dvb_thread
static int videobuf_dvb_thread(void *data)
{
struct videobuf_dvb *dvb = data;
struct videobuf_buffer *buf;
unsigned long flags;
int err;
void *outp;
dprintk("dvb thread started\n");
set_freezable();
videobuf_read_start(&dvb->dvbq);
for (;;) {
/* fetch next buffer */
buf = list_entry(dvb->dvbq.stream.next,
struct videobuf_buffer, stream);
list_del(&buf->stream);
err = videobuf_waiton(buf,0,1);
/* no more feeds left or stop_feed() asked us to quit */
if (0 == dvb->nfeeds)
break;
if (kthread_should_stop())
break;
try_to_freeze();
/* feed buffer data to demux */
outp = videobuf_queue_to_vmalloc (&dvb->dvbq, buf);
if (buf->state == VIDEOBUF_DONE)
dvb_dmx_swfilter(&dvb->demux, outp,
buf->size);
/* requeue buffer */
list_add_tail(&buf->stream,&dvb->dvbq.stream);
spin_lock_irqsave(dvb->dvbq.irqlock,flags);
dvb->dvbq.ops->buf_queue(&dvb->dvbq,buf);
spin_unlock_irqrestore(dvb->dvbq.irqlock,flags);
}
videobuf_read_stop(&dvb->dvbq);
dprintk("dvb thread stopped\n");
/* Hmm, linux becomes *very* unhappy without this ... */
while (!kthread_should_stop()) {
set_current_state(TASK_INTERRUPTIBLE);
schedule();
}
return 0;
}