kernel

What is the performance cost of a Win32 process switch?

I know the cost of a physical Win32 thread context switch is estimated at between 2-8k cycles. Any estimates on the cost of a process switch? ...

Linux Kernel: System call hooking example

I'm trying to write some simple test code as a demonstration of hooking the system call table. "sys_call_table" is no longer exported in 2.6, so I'm just grabbing the address from the System.map file, and I can see it is correct (Looking through the memory at the address I found, I can see the pointers to the system calls). However, wh...

printk - showing in message log but not in terminal for any kernel log level

I'm doing some kernel modification and am trying to get printk to output information back to the console. I pass any kernel log level with it and do not properly get any response back on the console for even the highest log levels. I checked and the current log configuration for printk is 4 4 1 7. It prints properly each time to logs. ...

restriction on using #define'd functions/inline functions inside Assembly files

Is there any restriction on using #define'd functions/inline functions inside Assembly files. I referred bsd kernel in which two different implementations are defined. One is macro and other is a normal function ( both are for same function) In the c file splx is defined asfunction, http://ftp.hu.freebsd.org/pub/netbsd/NetBSD-release-4...

Accessing variable in kernel-space from user-level space

Hello, So let's I have a struct that I want to read from user-level space that is defined in the kernel-space, but the user-level space has multiple processes. Example: In a kernel module, I have a global struct. struct { int a; int b; } test; In a user-level module, I have "externed" that global struct extern struct { int a; ...

Accessing a label from outside a function

The code: /* ctsw.c : context switcher */ #include <kernel.h> static void *kstack; extern int set_evec(int, long); /* contextswitch - saves kernel context, switches to proc */ enum proc_req contextswitch(struct proc_ctrl_blk *proc) { enum proc_req call; kprintf("switching to %d\n", getpid(proc)); asm volatile("pushf\n" ...

FCFS algorithm for linux kernel process scheduler

In linux kenel process scheduler there is a priority type SCHED_FIFO. I want to change the scheduling policy. I have two questions: 1- Where, in the kernel source code, is it mentioned that after a tick the cpu should belong to the interrupted process(Because in FIFO the process should remain until it finishes)? 2- In SCHED_RR where th...

Annotating IRQL changes in windows kernel code

Hi, I'd like to properly annotate the IRQL changes in a windows kernel driver, but I can't figure out how to do it right. Here are the functions: __drv_maxIRQL(APC_LEVEL) __drv_savesIRQLGlobal(evlist, list) __drv_setsIRQL(APC_LEVEL) void evlist_lock(evlist_s* list) { ExAcquireFastMutex(&list->lock); } __drv_requiresIRQL(APC_LEVEL) _...

Can I write Windows drivers with Delphi 2010?

I've always heard that Delphi can do almost anything C++ can do...except write Windows drivers. Is this correct, and if so, why is that? I recently read a blog post online that may indicate a possible solution for writing drivers with Delphi, but it's 3 years old and I don't know how accurate this information is. So, with the latest v...

A database-backed operating system

Here where I work I am attending a series of lectures about database query optimizers. While the speaker was introducing databases, he made a very insightful comment about a kernel having basically to administer tables of processes, pointers to open files, inodes, etc, and it's therefore basically a POSIX-compliant database engine. Clear...

Fastest way to pass a file's contents from Kernel to User mode?

I'll try to be brief, but fully descriptive: This is Windows-specific. Using the Windows Driver Development Kit (DDK). I am writing a Kernel Mode Driver (KMD) for the first time, having no prior experience in Kernel Mode. I am playing around currently with the "scanner" mini-filter sample which comes with the DDK, and expanding upon it...

Reducing Number of Registers Used in CUDA Kernel

I have a kernel which uses 17 registers, reducing it to 16 would bring me 100% occupancy. My question is: are there methods that can be used to reduce the number or registers used, excluding completely rewriting my algorithms in a different manner. I have always kind of assumed the compiler is a lot smarter than I am, so for example I o...

Shared Memory Bank Conflicts in CUDA: How memory is aligned to banks

As far as my understanding goes, shared memory is divided into banks and accesses by multiple threads to a single data element within the same bank will cause a conflict (or broadcast). At the moment I allocate a fairly large array which conceptually represents several pairs of two matrices: __shared__ float A[34*N] Where N is the nu...

some documentation/book about creating kernel modules for linux?

some documentation/book about creating kernel modules for linux? ...

Random Complete System Unresponsiveness Running Mathematical Functions

I have a program that loads a file (anywhere from 10MB to 5GB) a chunk at a time (ReadFile), and for each chunk performs a set of mathematical operations (basically calculates the hash). After calculating the hash, it stores info about the chunk in an STL map (basically <chunkID, hash>) and then writes the chunk itself to another file ...

Unusual high cpu utilization in ntkrnlpa:FsRtlAreNamesEqual and ntkrnlpa:RtlUpcaseUnicodeString

I am profiling a networking workload application on Windows XP. The VTune profiling result shows unusual high utilization on ntkrnlpa:FsRtlAreNamesEqual and ntkrnlpa:RtlUpcaseUnicodeString functions. From the module level, the workload spends 73% cpu time in ntkrnlpa.exe. In ntkrnlpa.exe module, 42% time is spent in FsRtlAreNamesEqual fu...

Linux Kernel - what function holds the source where port numbers are randomly chosen?

Anyone know what function or file in linux holds the algorithm that finds a random port to use for the bind() system call? I'm hunting all over and cannot find the method that contains this algorithm in the Linux source. Thanks! ...

Resources for writing kernel in C

I don't want to write my own boot loader -- happy to use Grub. I just want to implement pre-emptive multi threading, a basic file system, and virtual memory. I want something that can run on top of qemu. What's a good resource (book / tutorial) for accomplishing this goal? Thanks! ...

Books for understanding linux kernel?

To aid with poking around + running the linux kernel under qemu / UML; what are good books that describe how the linux kernel work? ...

Difference between processes running in kernel mode and running as root?

I am aware of the difference between a process running in user mode and one running in kernel mode (based on access restrictions, access to hardware etc.). But just out of curiosity, what is the difference between a process running in kernel mode and one running as root? ...