Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
i have written some really basic loadable kernel modules. There are a couple of concepts that i'll like to get cleared.
In a tutorial, the Makefile was given as follows-
obj-m += try.o
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
I understand that -C option of 'make' changes the current directory to /lib/modules/$(shell uname -r)/build (which depends on my kernel).
Now, my question is why to change to that particular directory? Also
M=$(PWD) will hold the dir where i have written the module. Why is it required? What does 'modules' at the end of that line indicate?
Q2> We need to include <linux/module.h> and <linux/kernel.h> in a module. If i am right, the module uses kernel headers for these definitions. But how does 'make' find these definitions.
Q3> We are planning to write a custom scheduler for linux kernel.
cat /sys/block/sda/queue/scheduler gives us the currently loaded schedulers. How do we expose our scheduler to linux kernel so that we can use it by switching to it.
make works only on Makefiles in the current working directory. The '-C' option tells make to first go to the specified directory, and use the specified target in the Makefile in that directory. This give make the capability of recursive building. The 'target' is one of the tokens at the left margin and followed by a ':' in a Makefile. The tokens 'modules' and 'clean' are such targets. Specifying a certain target tells make what part of the Makefile recipe it supposed to follow.
Make doesn't know how to find any C header files. Only C compilers know how to find header files. You may write rules in a Makefile that add to the C compilers list of places to look for header files.
To see how to add your scheduler, look through the Makefiles for an existing kernel, and see how the existing schedulers are enumerated. Add yours to the Makefile using a similar format. It may also require adding accordant entries to the kernel .config file.
A good understanding of the make tool is a valuable asset as a software developer. As a kernel developer, it is probably essential. I recommend finding one or more tutorials online to help you. Also, the man page for make has useful information.