Monthly Archives: February 2015

Introduction to Linux Kernel

What is Kernel?

Looking at the dictionary, the meaning of the kernel is core. But, as we know kernel refers to the operating system. So, what is kernel core of? In fact, kernel is the core of the overall system. Kernel is the system manager. It manages the system resources. So, what all are resources, we have in the system? This is explained as below:

CPU: This is one of the important resource, we have in system. It is the brain of the system. So, it is very important to optimally use this resource. Now, the question comes, how to manage the CPU. One of the mechanism to optimally use the CPU is, what we call as multitasking. Literal meaning of multitasking is doing more than one thing at a time. But, actually speaking, since in the uniprocessor system, we have a single CPU, so at a time, we execute only program, but to get the feeling of multi-tasking, kernel switches among the processes and switching happens to be so fast that, it seems like processor is executing all the processes at once. The subsystem in kernel which enables to achieve this multi-tasking is called scheduler. The task of managing the CPU is what we call as Process Management or Process Scheduling.

Memory: Another important resource, which we have in the system is the memory. When I say memory, it refers to the RAM. Since all the processes require the memory to execute, memory has to be shared among the processes in such a way that one process should not interfere with another process’ memory. Also, there is concept of virtual addressing, which gives the illusion of having more memory than the available RAM. So, subsystem of the kernel which does this task is memory manager. This task of managing the memory is known as Memory Management.

Input/Output (I/O): As you understand, system has various IO devices such as keyboard, mice, and speakers and so on. The task of managing the IO’s is what we call as IO Management.

Storage: This resource is used for storing the data in the non-volatile memory such as hard-disk. We usually store the data in form of files. So the subsystem in the kernel which deals with creation/deletion and management of files is Filesystem. This task of the kernel is what we call as Storage Management.

Network: In order to communication across the systems, we require the network. So, what needs to be managed in the network? There is networking protocol stack and the network interface card (NIC). The task of managing the network is what we call as Network Management.

So, to summarize, kernel performs the five main tasks – Process Management, Memory Management, I/O Management, Storage Management and Network Management.

Linux Kernel Source Organization

As you might be aware, Linux was developed by Linus Torvalds as an academic project. So, he started to create the directory for each functionality. Figure 1 below shows the kernel source code organization at a higher level.

 

kernel_source

 Figure 1: Linux Kernel Source Organization

As seen, there are directories corresponding to all the five functionality. Process management includes two things, one is the processor related code and the other is scheduling. So, all the CPU related code falls in the arch directory. It contains the directories for various processors. And, for scheduling, there are files starting with sched in directory kernel. For memory management, there is a directory called ‘mm’. So, all the code for managing the memory among the processes, shared memory, managing the mallocs, lies over here. Similarly, for most of the Input/Output management, there is folder called drivers. For storage management, there is directory called fs. It contains the code for various filesystem logic such as Ext2, Ext3, Fat32 and so on. For network, there is a directory called net which contains the code for protocols stack and in the drivers, there is a directory called net for interfacing with network interface card.

Apart from this, there are kernel and lib directories, which contain the architecture independent code in kernel. Similarly, linux directory, under include, contains the headers for architecture independent code in kernel. init contains the code which is used during the kernel boot-up.

Next Article >>

www.pdf24.org    Send article as PDF   

Building Circuits from Scratch

This is all about “Do It Yourself: Electronics”, as how it started between two college friends from NIT Warangal.

“Oh! It was a total tangential lecture today”, sighed Pugs in the cafeteria.

“Why? What happened Pugs? What was it about?”, asked Surya.

“Electronics Fundamentals, yaar”, replied Pugs.

“But, why in this world have you chosen that elective, you being a comps guy?”, asked Surya with curiosity.

“I wish to design some electronic circuits of my own. So thought, that might be helpful.”

“That sounds interesting. But I can understand, what would you have felt in the lecture. BTW, what was the topic today?”

“Don’t ask me yaar. All these electrons moving around, then these imaginary holes, the potential barriers, and what not. After initial 5 minutes, I was totally lost.”

“You know what? You don’t really need to know all these gory details to design basic electronic circuits. And moreover, you should go by the top-down approach to fulfill your wish.”

“O really! And what is this top-down approach”, exclaimed Pugs.

“What I mean is that you should first start playing with the various electronics components, understand their practical usages by designing simple breadboard circuits. And, then go into the gory details, if necessary”, explained Surya.

“That’s wonderful. Design the circuits first. Cool!! … But how do I start? I don’t have any clue about what components, etc”

“That’s easy. I can give you a practical hands-on kick-starter.”

“That’s great Surya. I hope after that I’d be able to start designing circuits, and may be able to make sense out of the lectures, as well.”

“Ya sure Pugs. Let’s go to my room. I have various electronics stuff there to get you started.”

“Just an idea. I know, I am going to get an amazing kick-starter, and there may be many more like me. So, why not record your kick-starter.”

“Hey! No yaar. It is just for you”, Surya replied shyly, thinking of the public exposure.

“Come on Surya. Think of it. Your knowledge sharing could benefit so many.”

“Hmmm!! …”

“Don’t think so much. I know that would thrill you. Let me get the photography club guys to film it.”

All set in Surya’s room, he took out his various electronics stuff, and started explaining them to Pugs, as follows:

Pugs was all excited after this first level of kick-starter by Surya, and requested Surya to show the video on resistor colour coding, as well.

Here is what Surya showed on his laptop:

“I understood what all you showed me. But how do I use the various things?”, queried Pugs. “Okay. So, I’ll now show you the simplest electronics circuit – ‘Blinking an LED'”, replied Surya. And, here is what he did:

“That was really simple. Something like the ‘Hello World’ program we write, when we start learning a programming language”, expressed Pugs. “Exactly, that’s what it is in the electronics world – blinking an LED”, confirmed Surya.

“Chalo Pugs, let’s go for lunch”, said Surya, trying to shutdown his laptop. Pugs interrupted, “Ay no Surya. Just before we go for lunch, I have a small doubt”. “Ya, tell me”, asked Surya. “Theoretically, you explained to me about the various current, voltage, resistor values from the datasheets etc, and then built the circuit. Do this circuit, really have those values?”, doubted Pugs. “What do you think?” asked Surya. “If you are asking means should be, otherwise how would the circuit work.”, Pugs tried to confirm with Surya. “Yes and No. They would be close to those values but not exact – and that is what is practical about it – to be tolerant about the tolerances. To drive the point home, I think, let me show you the actual readings using a Digital MultiMeter (DMM)”. And with that, Surya demonstrated the following measurements:

Next Article >>

www.pdf24.org    Send article as PDF