Re: [Question]How to restrict some kind of task?

From: Con Kolivas (kernel_at_kolivas.org)
Date: 11/15/05

  • Next message: Neil Brown: "Re: [PATCH ] Fix some problems with truncate and mtime semantics."
    To: liyu@ccoss.com.cn
    Date:	Tue, 15 Nov 2005 21:21:29 +1100
    
    

    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
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/


  • Next message: Neil Brown: "Re: [PATCH ] Fix some problems with truncate and mtime semantics."

    Relevant Pages

    • Re: [patch] voluntary-preempt-2.6.9-rc3-mm2-T0
      ... > fundamentally wrong - ksoftirqd must never use that much CPU time on an ... would you try this patch below that I posted yesterday? ... today realize it's probably what I've been hunting - I'm ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: 2.6.14 kswapd eating too much CPU
      ... cat /proc/zoneinfo gets you ... Also - when you say "too much cpu time", ... Send instant messages to your online friends http://au.messenger.yahoo.com ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: RFA: Changing scheduler quantum (Was: REQUEST: OpenLDAP 2.3.7)
      ... tell us what the kernel should do all over again. ... multiple tasks are running prior to expiration on the active runqueue. ... wanting cpu time on the active runqueue. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: PATCH: cdrecord: avoiding scsi device numbering for ide devices
      ... >> An option to reserve some portion of CPU time for ... I hate to derail a good flame-fest, but this would be extremely useful, ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)

    Loading