Results 1 to 7 of 7
Hi all,
I've been trying to simply use printk for a while now as I'm doing a little kernel
modding, however, things aren't going as smoothly as I would've wished.
...
- 02-28-2010 #1Just Joined!
- Join Date
- Feb 2010
- Posts
- 7
Printk defined loglevels not found
Hi all,
I've been trying to simply use printk for a while now as I'm doing a little kernel
modding, however, things aren't going as smoothly as I would've wished.
Here's the very simple code:
For whatever reason, it can't find the definition for "KERN_DEBUG" (or anyCode:#include <linux/kernel.h> int main() { printk(KERN_DEBUG "This is a test\n"); return 0; }
defined log level for that matter) even though I can clearly see them DEFINE-d
in /usr/src/kernel/linux-2.26.8-57/include/linux/kernel.h .
I'm at a loss as to what is causing this.
Any ideas would be most appreciated.
Thank you,
-Elleroth
(Oh and this was my first post ever on the Linux Forums! Yay me)
- 02-28-2010 #2
I believe printk can only be used in kernel modules not user processes..
This guide should start in the right direction...
The Linux Kernel Module Programming GuideMake mine Arch Linux
- 02-28-2010 #3Just Joined!
- Join Date
- Feb 2010
- Posts
- 7
Excellent.
Looks like it compiled okay after embedding it into kernel/sched.c so I'm going to assume that you're correct.
Thanks,
-Elleroth
- 03-01-2010 #4Just Joined!
- Join Date
- Feb 2010
- Posts
- 7
Well it seems to be in the kernel, but it doesn't want to print.
The message is nowhere within /var/log/ and I can't get it to print to any log or the
terminal. (I even tried fiddling with /proc/sys/kernel/printk but that didn't seem to
help.)
Everything compiled beautifully; What could have gone wrong?
-Elleroth
- 03-01-2010 #5
You'll have to post some code for any reasonable answers...
Make mine Arch Linux
- 03-01-2010 #6Just Joined!
- Join Date
- Feb 2010
- Posts
- 7
Sorry... I assumed that since it compiled properly, it wouldn't be necessary.
Here's the code (modified sched_rt.c; lines 1767 - 1789):
Seems like it should work, but I'm getting no messages sent anywhere.Code:/* * Function: getTimesliceRatio * * Returns the number of processes that are siblings of the * process defined by the task_struct passed-in. */ int getTimeSliceRatio(struct task_struct *ts) { //Get the sibling list head int timeslice_ratio = 1; struct list_head head_struct = ts->sibling; struct list_head *head = head_struct.next; while(head != NULL) { if(head->next != NULL) //...and if next node is NOT NULL { head = head->next; timeslice_ratio++; } else //...Otherwise the list is exhausted { } } printk(KERN_DEBUG "Number of siblings for process %d is: %d\n", ts->pid, timeslice_ratio); //Return the number of siblings that this process has return timeslice_ratio; }
Thanks for all your speedy replies,
-John
- 03-03-2010 #7Just Joined!
- Join Date
- Feb 2010
- Posts
- 7
I've just been informed that I cannot use these forums for aid on school assignments. Please close this thread (everything is working now anyway).


Reply With Quote