Questions tagged [kernel]
Code that is intended to run in an operating system kernel or kernel module
29 questions
1
vote
0
answers
114
views
MemoryGraveyardDriver.sys - a kernel mode device driver managing a kilobyte of RAM for random reading/writing: Take II
(See the previous and initial iteration.)
This time I have incorporated some improvement points made by G. Sliepen:
driver.cpp:
...
8
votes
1
answer
552
views
MemoryGraveyardDriver.sys - a kernel mode device driver managing a kilobyte of RAM for random reading/writing
(See the second and next iteration.)
Intro
I have this GitHub repository. Basically, it does not do anything fancy: it has a byte buffer of 1Kb size, and it intercepts ...
2
votes
0
answers
101
views
4
votes
2
answers
360
views
LKM: Extract cpu model name from /proc/cpuinfo
I wrote a small LKM that opens the /proc/cpuinfo file, reads it line by line, and attempts to the cpu model name.
If the function fails to extract the cpu model ...
4
votes
1
answer
546
views
Simple slab allocator in C
Here is the plan:
a slab takes up 1 page and it has PGSIZE / blocksize amount of blocks
the minimum blocksize is 8 bytes, otherwise the pointer to the next block ...
2
votes
1
answer
404
views
Thread scheduler in C
I have made a simple round robin scheduler that switches between threads in ptable array. Currently it's only for 1 CPU, so there are no locks at the moment.
But ...
1
vote
1
answer
364
views
Virtual memory manager in C
Virtual Memory manager that has functions, mappage, unmappage, remappage
If the physical ...
3
votes
1
answer
370
views
Bitmap page allocator in C
Bitmap page allocator that scans the bitmap linearly looking for size amount of pages. Everytime it founds a free page, it check if the next ...
3
votes
1
answer
285
views
UEFI bootloader
UEFI bootloader.
It reads the file kernel.elf on the disk image, reads through the program headers, copies the LOAD segments into memory, and finally calls ...
2
votes
0
answers
91
views
Virtual memory manager, physical memory manager and buddy allocator
I'm writing memory manager for my toy operating system and I would like to get some feedback. There is physical memory manager, which uses bitmap, virtual memory manager which uses buddy algorithm for ...
2
votes
0
answers
328
views
OSDEV Physical Memory Manager (PMM) in C
I ported the Physical Memory Manager from Vinix into C for a little OS I'm working on. I'd love to get some feedback.
Here's my code:
...
1
vote
1
answer
413
views
Implement 2D and 1D std::array in opencl kernel
I am asked to implement the following part of code into kernel code. Actually, I have tried but not sure about the std::array.
This is the original code for the ...
2
votes
2
answers
261
views
Makefile to compile an OS which also uses functions/macros
So I've started writing an OS to know how they work, and I came up with the following makefile to compile it.
The reason I used a makefile is because I wanted to see everything it was doing and have ...
4
votes
2
answers
180
views
Posix signal implementation
My hobby is Unix-like operating systems.
Recently I began writing my own sel4-based Posix compliant OS. Here's the code for internal signal handling functions which presents a kind of backend to help ...
4
votes
0
answers
82
views
Choose a kernel for next system boot
I have been testing a number of kernel builds and I decide to have a go at writing some Python code. The idea is to select which kernel to boot on the next reboot. I could have done it in Bash but ...
5
votes
1
answer
305
views
Creating procfs entry on linux in Kernel Module
My Linux kernel version is
Linux version 5.0.0-29-generic
I'm currently learning how to write kernel modules for Linux and implemented this simple module which ...
2
votes
0
answers
60
views
Getting an element from RCU-protected list in kernel
I wrote a function, read_fox_rcu() for getting an element from RCU-protected list in a linux device driver. read_fox_rcu() reads ...
2
votes
0
answers
126
views
CUDA kernel to compare matrix entries, weighted with a pattern
I wonder if it's possible to optimize this code in CUDA. Could I get any hints how to? Equivalent algorithm runs faster in Matlab for me, but there I'm doing matrix operations.
Compution
I'm not ...
5
votes
1
answer
1k
views
Linux GPIO rotary encoder as volume control
I've written a kernel module (tested on Raspberry Pi) to use a rotary encoder as a volume control.
The Linux source tree already contains a driver for rotary encoders so I've just piggybacked off of ...
4
votes
1
answer
136
views
ReadWriteSerializer
I am developing a C++ kernel, and I've got the need for manipulating huge data structures before the task-scheduler runs - it means in a non-preemptive environment.
For this, I have developed a read-...
7
votes
2
answers
699
views
Generating bounded & unique random numbers in the Linux kernel
I recently needed to generate a series of unique random numbers (non-repeated) within a bounded range inside of the Linux kernel. The code I came up with is below. I'd appreciate any feedback -- again,...
7
votes
1
answer
159
views
X86 Legacy boot loader error trapping
The boot loader that I'm designing is just simply going to setup (A) Stack, (B) Segment registers (C) Load remainder of track for specified device. Conventionally, this could have been up to 4 floppy ...
11
votes
1
answer
311
views
Makefile for a custom operating system kernel
I'm now posting the second semi-complete part of my operating system makefile. The kernel itself is currently incomplete, so don't be surprised by the small size of the makefile. When the kernel ...
4
votes
1
answer
1k
views
Re-implementing memcpy
I have written an implementation of memcpy function and I want to know how good is it and if it gets the most out of the processor capabilities or not.
The reason ...
11
votes
1
answer
2k
views
Callback in Linux kernel driver in order to hide device's low-level protocol
I'm am writing a Linux kernel driver for HD44780 LCDs connected via I2C bus. In my last change I tried to decouple low-level code (which talks to the device via I2C) from device's logic (printing ...
5
votes
1
answer
201
views
Kernel development
I'm trying to learn more about kernels, so naturally I started to program one. I'm using tutorials from here. Right now I have modified the printf() that was ...
7
votes
1
answer
371
views
Homebrew std::string for use with kernel
I've ported some standard library facilities like vector, algorithm, etc. to my kernel so I can code in C++ instead of C. This is one of them. I'm looking for concerns regarding:
Performance
Safety
...
14
votes
2
answers
2k
views
Free a binary tree without using recursion or allocating memory
As the title says, the objective is to free a binary tree without using the stack or allocating memory.
This was required for a kernel module where resources were limited.
Result has a complexity of \...
3
votes
2
answers
3k
views
Simple Linux char driver
Since the resources I found to learn are generally out-of-date, I'm having to read a lot of documentation, which makes the learning process somewhat haphazard. The module makes a simple character ...