(Before I published an article on the CUSEC website about the kernel is not scary, this article is follow-up.) )
I once asked others how to start the kernel programming study, they basically said:
1. If you don't need to know how the kernel works for you, why should you try it?
2. You should subscribe to the Linux kernel mailing list and then try to understand.
3. If you don't write code for the Linux kernel, you're wasting your time.
None of this helped me a bit. So here's a list of possible ways to work with the operating system and the Linux kernel on your project, and it's interesting. I don't know much about it, but at least I know more about it than I did before.
For the following ways, you just need to know some C language and assembly language (at least copy and paste). I will write some small C programs, but also to use the Assembly to class, although I forget the same.
Method One: Write your own operating system
This seems to be a pretty scary way. But not really! I started with the Rustboot project, and it's important that it's ready to work. Then I will do something simple, such as turning the screen from red to blue, printing characters to the screen, and continuing to get keyboard interrupts to work.
MikeOS is another interesting start for me. Keep in mind that your operating system does not have to be very professional-if you can make it change the color of the screen from red to purple or let it print a poem, you succeed.
You will want to use an emulator to run your operating system, such as QEMU. The Osdev wiki is also a useful site-there are a lot of common problems that you will encounter.
Method Two: Write some kernel modules!
If you're ready to run Linux, it's pretty easy to write some kernel modules, even if they don't do anything.
Here's a can print "Hello, hacker school!" Module source code to the kernel log. It has only 18 lines of code. Basically you just have to write an init process and a cleanup function. I don't know what __init and _exit have done with these two macro commands, but I'll use them!
It is difficult to write a kernel module with a certain function. When I do this, I decide what I want to accomplish (like printing a message to every kernel packet), then go back and read something on Kernel newbies, use Google to search a lot, copy and paste a lot of code to figure out how to write it. Here are a few examples of kernel modules, and I put them in the Kernel-module-fun project.
Method Three: Participate in a Linux kernel internship!
The Linux kernel team participates in the GNOME Women's Outreach Internship program. It is an amazing, wonderful and delightful activity. This means that if you are a woman and willing to spend three months on kernel development, you will be able to participate in the development of the kernel without any experience and get some compensation ($ 5000). There is an introduction to it on Kernel newbies.
If you're interested in this, it's very worthwhile to apply-you can make a formatted patch for the kernel, which is very interesting. Sarah Sharp is a Linux kernel developer who is coordinating this activity and she is very enthusiastic about it. You can read this blog post about how 137 patches were allowed to be added to the kernel in the first round. These patches will also be available to you! View Application Instructions!
If you are not a girl, then you can choose Google Summer of code this similar activity. (Note: This sentence may cause the female programmer to resent)
Method Four: Read the kernel source code
It sounds like the worst advice--"It's stupid to see the source code if you want to know how the kernel works."
But in fact this method is very interesting. You don't need to know anything. When it comes to things I can't understand, I feel powerless, but when I tell people, everyone says, "Well, this is the legendary Linux kernel, and you can't understand it properly!" ”
My friend Dave recently gave me a website LXR, where you can read the resources of the kernel, and also provide a lot of useful reference links. For example, if you want to know the system call to chmod This command, you can see the definition on the Chmod_common definition page about it in the Linux kernel!
Here are some of the parts of the Chmod_common code, some of which I wrote notes:
static int Chmod_common (struct path *path, umode_t mode) {struct Inode *inode = path->dentry->d_inode; struct iattr newattrs; int error;//do not know what this is doing error = Mnt_want_write (PATH->MNT); if (Error) return error; //Mutual exclusion lock! Avoid the phenomenon of conflict!=d mutex_lock (&inode->i_mutex); //I guess this is checking if you can use chmod error = security_path_chmod (path, mode); if (Error) goto out_unlock; //I guess this is changing the value of mode Newattrs.ia_mode = (Mode & S_iallugo) | (Inode->i_mode & ~iallugo); Newattrs.ia_valid = Attr_mode | Attr_ctime; Error = Notify_change (Path->dentry, &newattrs); Out_unlock:mutex_unlock (&inode->i_mutex); //complete when the mutex is lifted Mnt_drop_write (PATH->MNT); //??? return error;}
I think this process is very interesting, but also helped me clarify the meaning of the kernel. I find that most of the code I read is hard to understand, but there are some (such as chmod code) that are understandable.
Summarize several links:
- Jessica McKellar blog post on Ksplice blog
"Linux Device Drivers" describes its own, I find it is still a bit of a use:
"This book teaches you how to write your own drive and how to invade a kernel-related place."
If you are writing an operating system, the Osdev Wiki is a good site
- Kernel Newbies has some resources for the kernel developers, although I have some unpleasant experiences in its chat room.
- Sarah Sharp is a kernel developer who is responsible for the Linux kernel's external services and is a very good woman.
Original: 4 paths to being a kernel hacker
Reprinted from: Bole Online-Haofly
http://segmentfault.com/a/1190000000382157http://segmentfault.com/a/1190000000382157
http://blog.csdn.net/xiangpingli/article/details/44428155
Four ways to become a Linux kernel master