kernel

Do most modern kernels use DMA for network IO with generic Ethernet controllers?

In most modern operating systems like Linux and Windows, is network IO typically accomplished using DMA? This is concerning generic Ethernet controllers; I'm not asking about things that require special drivers (such as many wireless cards, at least in Linux). I imagine the answer is "yes," but I'm interested in any sources (esp. for t...

How to add assembly code in Linux

I am writing a Linux kernel module on Fedora core 6 and I am wondering if anyone could tell me how to add the assembly code shown below to my program. The assembly code was written for Windows and I have no idea how to convert to Linux kernel program. #ifdef _MSC_VER unsigned char lookKbits(char k) { _asm { mov dl, k ...

Linux - identify process owning a specific address in physical memory

Under Linux, how can I tell what specific process owns / is using a given address in physical memory? I understand that this may require writing a kernel module to access some kernel data structure and return the results to a user - I need to know how it can be done, regardless of how complicated it is. ...

How to clean caches used by the Linux kernel

I want to force the Linux kernel to allocate more memory to applications after the cache starts taking up too much memory (as can be seen by the output of 'free'). I've run sudo sync; sudo sysctrl -w vm.drop_caches=3; free (to free both disc dentry/inode cache and page cache) and I see that only about half of the used cache was freed...

Getting inode from path in Linux Kernel

I'm currently trying to get an inode for a given pathname in a kernel function. All I have available is the full pathname. I've tried attempts like: user_path_at(AT_FDCWD, buffer, LOOKUP_FOLLOW, &path); But the dentry in that given path isn't valid, it seems to turn out. Then I thought perhaps trying stat() and getting the inode numbe...

Server running in linux kernel. Should listen happen in a thread or not?

I am writing a client/server in linux kernel (Yes. Inside the kernel. Its design decision taken and finalised. Its not going to change) The server reads incoming packets from a raw socket. The transport protocol for these packets (on which the raw socket is listening) is custom and UDP like. In short I do not have to listen for incoming...

How frequently IP packets are fragmented at the source host?

I know that if IP payload > MTU then routers usually fragment the IP packet. Finally all the fragmented packets are assembled at the destination using the fields IP-ID, IP fragment offsets and fragmentation flags. Max length of IP payload is 64K. Thus its very plausible for L4 to hand over payload which is 64K. If the L2 protocol is Ethe...

Kernel.loop method requires 'do' - semicolon not allowed?

LOOP This works with do: x=0 loop do puts x; x+=1; break if x == 100 end but not with a semicolon: x=0 loop; puts x; x+=1; break if x == 100 end UNTIL However, this works with 'do': until x == 100 do puts x; x+=1 end and with a simicolon: until x == 100; puts x; x+=1 end With certain Ruby syntax I have a choice of u...

Developing kernels and testing them in virtual machines

I like programming challenges, and writing a kernel seems a programming challenge. Unfortunately, kernels are particularly hard to test because they are basically the core of operating systems and so they can't be easily ran on top of an operating system. However, I know about applications called Virtual Machines that can emulate compu...

Entries in /proc/meminfo

I can make sense of most of the information contained in /proc/meminfo like total memory,buffers, cache etc. Could you tell me what do the less obvious ones like *AnonPages,Mapped,Slab,NFS_Unstable,Bounce,VmallocTotal,VmallocUsed,VmallocChunk* mean? ...

Memory usage of a kernel module

While trying to estimate the amount of memory consumed by a kernel module (usually device drivers),I tried using the size utility which gave the size of the static memory areas of the .ko ( .bss, .data, .text etc). So I was expecting the sum of these values to be exactly equal to the output given by the lsmod command immediately after in...

Putting code and data into the same section in a Linux kernel module

I'm writing a Linux kernel module in which I would like to have some code and associated data in the same section. I declare the data and the functions with the attribute tags, like: void * foo __attribute__ ((section ("SEC_A"))) = NULL; void bar(void) __attribute__ ((section("SEC_A"))); However when I do this, gcc complains with: e...

How to build a kernel image using Visual Studio

I'd like to build an embedded kernel for an x86 machine using Visual C++. I have some C and assembly code files to compile and I'd like to link them all together in a way that is compatible with a Multiboot bootloader like GRUB. ...

What source files can I read for learning C?

I want to learn C languages and I'm running a Linux distro (Ubuntu) so I would like to know where can I begin? I know some people will tell me to read K&R books or others but I want to pratice C, not theory. So I believe that reading C sources and changing some words will help me to understand. So what are the sources for a beginner? ...

Does Boot loader mind kernel import declarations?

I wonder whether the Windows XP bootloader (ntldr) actually makes use of the Windows kernel (ntoskrnl.exe) import declarations? ntoskrnl.exe has following imported modules: BOOTVID.dll, HAL.dll and KDCOM.dll. So these three modules are the first ones to be loaded. Imagine that the kernel has another module declared as imported. Will th...

making g++ ignore -mregparm for certain code

Some background: As a personal project, I've been developing a kernel in c++. Things are going well, in fact I have very good support for much of c++ available in kernel land (I've implemented nearly the entire libc and libstdc++). One of the more difficult and compiler specific things is RTTI and exception support. For now I'm disabli...

Operating System Scheduling Algorithms

What is the best algorithm to use for scheduling an application that will support 10K concurrent threads with heavy I/O but low CPU usage? Links to papers are appreciated. ...

Why I can not ban the operation of

I write a driver to attach on MountPointManager and filter all IOCTL_MOUNTMGR_DELETE_POINTS IRP. But after I return this IRP with code below, I see no volume letter left. Irp->IoStatus.Status=STATUS_INVALID_PARAMETER; Irp->IoStatus.Information=0; IoCompleteRequest(Irp,IO_NO_INCREMENT); return STATUS_ACCESS_DENIED; Anyone could help me...

Converting kernel image from ELF to PE

I am using Msys to build a home brew kernel that I wrote under Linux. Linux used ELF for its binary format and Msys uses PE. I have the source setup to allow it to be booted by Grub using the Multiboot spec. At the end of the build, I get some undefined symbols: init.o:init.S:(.text+0x14): undefined reference to `edata' main.o:main....

Using boost in WDK build environment for applications?

I am using the Windows Driver Kit (WinDDK 6001.18001) to build my userspace application rather than Visual Studio 2005. I am taking this approach because we also have to build driver components, so I'd prefer to have a single build environment to build everything. Microsoft itself uses this approach for several products. This was workin...