Re: Strange behaviour with Xilkernel



Hello Paco,

With the new code you post I think the problem is the same.
The problem is not only the time spent in context switch, also the
time in system calls is important: pthread_create and pthread_join are
both system calls that will spent many cycles running with interrupts
disabled (can't guess how many, but probably equal or more than a
context switch, you can measure it with another timer if you are
interested in the exact time it's spent).
If you are interested in measuring the time some functions spent, I
recommend you to use another timer and not to use the
xget_clocks_ticks(). If you use another timer, you can use it to count
exact cycles a function call spends, instead making 100000 calls and
calculating the mean time.

Answering your questions:
"Is too heavy the context switch in Xilkernel?" I think it is not too
heavy. I have studied the code and it's quite optimal. If you are
interested I can measure how many cycles it spends.
"Is the context switch done with interrupts disabled?" Yes. A context
switch can be reachead by two ways: a timer interrupt, or a system
call like yield(), pthread_join(), pthread_exit(), etc. In both
situations the interrupts are disabled.

Best regards,

Pablo H

PD. Saludos a Pablo. Cualquier cosa que pueda ayudar no dudes en
preguntar.


Pablo,

I appreciate very much your advices. I will try to use another timer as
you point out.

Saludos,
Paco


.



Relevant Pages

  • Re: Strange behaviour with Xilkernel
    ... The problem is not only the time spent in context switch, ... you can measure it with another timer if you are ... "Is the context switch done with interrupts disabled?" ...
    (comp.arch.fpga)
  • Re: [PATCH] s390 (9/9): no timer interrupts in idle.
    ... Some time ago I put together a tick less ... On context switch the scheduler needs to figure the minimum time to the next ... profile timer, virtual time, and the cpu limit timer. ... I.e. the tick less system incurres accounting overhead in direct ...
    (Linux-Kernel)
  • Re: [PATCH] s390 (9/9): no timer interrupts in idle.
    ... On the HRT sourceforge page you'll find the i386 version of the tick less system ... > profile timer, virtual time, and the cpu limit timer. ... > added context switch over head with a medium cpu load. ... a store cpu timer "stpt" and a set cpu timer "spt" to switch from the process ...
    (Linux-Kernel)
  • Re: [RFC][PATCH] new timeofday core subsystem (v.A0)
    ... Why does the context switch overhead ... > takes a bit of time, not much, but enough to increase the context switch ... > more timer management overhead than the periodic tick generates. ... I thought that the timer handling could be separate from the time slice ...
    (Linux-Kernel)
  • [patch] cleanup context switch locking
    ... for interrupts to be enabled over the context switch. ... +#ifdef CONFIG_SMP ... * This is called with the rq lock held and interrupts off. ...
    (Linux-Kernel)