From: Con Kolivas <kernel@kolivas.org>
To: liyu@ccoss.com.cn
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [Question]How to restrict some kind of task?
Date: Tue, 15 Nov 2005 21:21:29 +1100 [thread overview]
Message-ID: <200511152121.30107.kernel@kolivas.org> (raw)
In-Reply-To: <4379B5EB.40709@ccoss.com.cn>
On Tue, 15 Nov 2005 21:18, liyu wrote:
> Hi, All.
>
> I want to restrict some kind of task.
>
> For example, for some task have one schedule policy SCHED_XYZ, when
> it reach beyond
> 40% CPU time, we force it yield CPU.
>
> I inserted some code in scheduler_tick(), like this:
> > if (check_task_overload(rq)) {
> > if (xyz_task(p) && yield_cpu(p, rq)) {
> > set_tsk_need_resched(p);
> > p->prio = effective_prio(p);
> > p->time_slice = task_timeslice(p);
> > p->first_time_slice = 0;
> > goto out_unlock;
> > }
> > }
>
> Of course, before these code, we hold our rq->lock first, so we should
> go to 'out_unlock'.
> The function xyz_task(p) just is macro (p->policy == SCHED_XYZ), and
> yield_cpu() also is simple, it just move the task to expired array,
>
> int yield_cpu(task_t *p, runqueue_t *rq)
> {
> dequeue_task(p, p->array);
> requeue_task(p, rq->expired);
> return 1;
> }
Don't requeue after dequeue. You enqueue after dequeue.
Con
next prev parent reply other threads:[~2005-11-15 10:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-15 10:18 [Question]How to restrict some kind of task? liyu
2005-11-15 10:21 ` Con Kolivas [this message]
2005-11-16 1:16 ` liyu
2005-11-17 6:20 ` liyu
2005-11-17 9:57 ` Con Kolivas
2005-11-18 8:37 ` [Question] spin_lock in interrupt handler liyu
2005-11-18 22:44 ` Steven Rostedt
2005-11-21 1:13 ` liyu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200511152121.30107.kernel@kolivas.org \
--to=kernel@kolivas.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liyu@ccoss.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox