![]() |
| | #1 |
| Registered User Join Date: Oct 2007
Posts: 47
| kernel hacking, plz help 1. When a rt-task is about to be preempted in the rt-class the task_preempt_curr_rt(..) is called, is this correct? 2. When a rt-task is running in the CPU the function task_tick_rt(..) is called every tick, 1 tick = 1ns by default. Is this correct? 3. When a rt-task gets blocked the function dequeue_task_rt(..) is called, is this correct? 4. When a rt-task wakes up from being blocked, either enqueue_task_rt(..) or requeue_task_rt(..) is called, is this correct? 5. If i want to account for CPU-time in a rt-task, which clock to use? will sched_clock() be a good choice? I'm pretty sure about 1 and 2, but not so sure about 3, 4 and 5, any help is welcome. Thanks. |
| micke_b is offline | |
| | #2 | ||||||
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Quote:
Quote:
The time may be measured in nanoseconds, but it's certainly not interrupting every one of them - it's either measuring chunks of say 500-10000 ns at a time, or, if more precise time is required, it's using other ways to determine the time (e.g. the TSC). Quote:
Quote:
Quote:
Quote:
Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. | ||||||
| matsp is offline | |
| | #3 |
| Registered User Join Date: Oct 2007
Posts: 47
| Thanks for the answers. Of course you are right about the tick func not being called every ns. But I'd want to get the time every tick. And for this you mean that TSC is better then sched_clock()? with TSC you mean from include/asm/tsc.h? the: get_cycles(..)? I also noted in this file the get_cycles_sync(..) and tsc_init(..) functions. Do I need to init this clock()? In the header it says about get_cycles_sync(..): /* Like get_cycles, but make sure the CPU is synchronized. */ synchronized with other CPUs? If so I only need to call the get_cycles(..) and this will give me the number of clock cycles? sinze tsc_init() was called? Is it automatically called? thanks |
| micke_b is offline | |
| | #4 |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Yes, get_cycles() should do that you want, generically. No, sync just means that it's forcing the instructions before RDTSC to be "forced out" before the TSC is being read. sched_clock() may give the same result, but with a whole heap of extra overhead, as it uses multiple different sources to get the current time. Note that if you switch from one CPU to another, RDTSC is not a good solution - I think sched_clock() would be the right solution then - but I'm not sure. This is because TSC can shift from one CPU to another. -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. |
| matsp is offline | |
| | #5 |
| Registered User Join Date: Oct 2007
Posts: 47
| Ok, thanks again. No-one that knows how long this tick-interrupt is? how often do task_tick_rt() get called? how to check? |
| micke_b is offline | |
| | #6 | |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Quote:
However looking at: http://lxr.linux.no/linux/kernel/sched_rt.c#L233 leads to: http://lxr.linux.no/linux/kernel/sched.c#L3333 It seems like it's called as often as HZ says - which is one of the configurations in "xconfig" or "menuconfig" in your Linux kernel. -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. | |
| matsp is offline | |
| | #7 |
| Registered User Join Date: Oct 2007
Posts: 47
| Ok, when I check my menuconfig I find the "timer frequenzy" set to 250HZ is this it? so every 4ms then? |
| micke_b is offline | |
| | #8 | |
| Kernel hacker Join Date: Jul 2007 Location: Farncombe, Surrey, England
Posts: 15,686
| Quote:
If you want more finegrain timing, you can probably crank it up to 1000Hz -> 1ms. Much more than that and you will suffer from too much overhead, not enough work done, as not only does the interrupt itself take up time, but everything done in a timer-tick (including the scheduler-related work, but also ticking up time outs etc) will be done every time. Possibly 10000Hz is reasonable on a modern processor - but with some loss of performance for sure. -- Mats
__________________ Compilers can produce warnings - make the compiler programmers happy: Use them! Please don't PM me for help - and no, I don't do help over instant messengers. | |
| matsp is offline | |
| | #9 |
| Registered User Join Date: Oct 2007
Posts: 47
| Ok, thanks Mats, really helped a lot as usually. |
| micke_b is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Kernel Hacking Issue | NuNn | Linux Programming | 1 | 03-31-2009 12:54 PM |
| SOS - Can a monolithic kernel be used in a micro-kernel style OS? | sean | General Discussions | 7 | 11-20-2008 09:30 AM |
| more kernel hacking, the check_preempt_curr_rt() func | micke_b | Linux Programming | 2 | 02-18-2008 11:03 AM |
| CreateThread ?! | Devil Panther | Windows Programming | 13 | 11-15-2005 10:55 AM |
| Kernel hacking | Spark | C Programming | 7 | 06-20-2002 08:40 PM |