linux-kernel

Making a user space thread library with pthread, how do you properly create the first thread? (well first 2 threads)

So im making a user space thread library. lets say theres some program that uses it. in that program it starts at the main method. before any calls to create_thread, there are no threads active. then when the first thread is created, the library makes 2 threads. One for 'main' and one for the actual new thead you are making. This is th...

detecting nic and ports on systems loaded with linux

Hello All, Is there a simple way to detect nic and associated ports on systems loaded with linux. From my study on this, i found lshw -C network would help me to some extent, by giving details on ports and interfaces. But i didn't get clear differentiation done with nic and associated ports. Say if i have 2 nic cards with one 4 ports...

Does running an SMP kernel on a single-cpu machine hurt performance?

On my Ubuntu machine, default kernel image which is running is built for smp (CONFIG_SMP=y). But this machine has only 1 cpu. On uni-processor kernel, unlike smp kernel, spin_lock/unlock are null functions. So how does spin_lock() and spin_unlock behave in this setup? Is there any performance impact due to such smp specific code? ...

Linux 3/1 virtual address split

I am missing something when it comes to understanding the need for highmem to address more than 1GB of RAM. Could someone point out where I go wrong? Thanks! What I know: 1 GB of a processes' virtual memory (high memory region) is reserved for kernel operations. The user space can use the remaining 3 GB. This is the 3/1 split. The...

Running ctags for an external kernel module ( or pulling in tags from a separate related project )

I'm building a an 'external' module ( device driver ), i.e. it's not in the Linux kernel source tree, but in a separate unrelated source tree. I want to use ctags to browse variable / function declarations and definitions that are being pulled in from the kernel via header files. For example assuming I have: ~/src/kernel-source ~/src/...

Using the new ( since Linux Kernel 2.6.20 ) workqueue interface

I've been reading about Linux Kernel development / device drivers and all of the books I've looked at use the pre-2.6.20 workqueue interface. This includes the Linux Kernel Module Programming Guide, Robert Love's Linux Kernel Development, and Sreekrishnan Venkateswaran's Essential Linux Device Drivers which was published in April 2008! ...

Overview of Linux boot late_time_init() in start_kernel()?

There's a part of the Linux boot sequence I don't understand and an overview would be immensely helpful. Specifically the WARN_ON_ONCE(!irqs_disabled()) in sched_clock.c::sched_clock_tick() is triggering and I'd like to trace back to where the interrupts are disabled. Knowing the call tree is one thing (as seen below), but since there a...

How can I test my driver is loaded, and then access my driver functions from the linux kernel?

I have a driver which compiles and loads into the linux kernel just fine. In this driver are some functions which I would like to access from the kernel file 'fs/readdir.c'. Additionally, how can I test if a driver is loaded? I need something like the following. if(myDriver is loaded){ myDriver.functionCall(); } All examples I've...

Reading from a block device in kernel space

Hello I am writing a kernel module and need to perform reads from an existing block device. (/dev/something). Does anyone know of any other modules that do these that I can use as reference ? Any pointers would be welcome (Linux.2.6.30) ...

How to make effective use of the Linux Kernel Documentation directory?

This may seem like a kind of amorphous question, but how can you get the most of the Linux Kernel Documentation directory? I noticed on the Linux Cross Reference that there is a DocBook directory. How do I build it, use it and is it at all useful? What other ways are there to make efficient use of this directory? ...

Kernel threads and POSIX library

How does one create a Kernel Thread using Posix library? ...

A few /proc and /dev questions

(1) Is /proc always present on all linux systems or is it an option somewhere (e.g. kernel compile, boot, etc)? (2) What determines what sub-directories are present in /proc? Are these always the same or are they configurable and/or creatable by user-space programs (presumably run as root)? (3) I noticed that /dev/shm was present on m...

What Data Structures are available in the Linux Kernel

Is there a list somewhere of all the major generic data structures used in the Linux Kernel and as a side bonus major places they're used? What I mean by "generic data structures" is things like doubly linked lists, hash lists, timer wheels, etc. Also, which ones are considered part of the internally provided api available to modules...

C memcpy() a function

Hi guys, Is there any method to calculate size of a function? I have a pointer to a function and I have to copy entire function using memcpy. I have to malloc some space and know 3rd parameter of memcpy - size. I know that sizeof(function) doesn't work. Do you have any suggestions? ...

Configuring kernel

After create a new system call, how to update the kernel? I tried these lines, make-kpkg clean fakeroot make-kpkg -initrd -append-to-version=-custom kernel_image kernel_headers But Ubuntu asked me if I am sure what I am doing, or not. But I am not sure. Do I have to say yes? Here is what did, Ubuntu said to me: You are attemptin...

Relation between USB and PCI

Hi, I m bit confused by the following statement in linux device drivers book. http://www.linuxdriver.co.il/ldd3/ 13.2. USB and Sysfs To help understand what this long device path means, we describe how the kernel labels the USB devices. The first USB device is a root hub. This is the USB controller, usually contained in a PC...

Kernel Panic after changes in sys_close

I'm doing a course on operating systems and we work in Linux Red Hat 8.0 AS part of an assignment I had to change sys close and sys open. Changes to sys close passed without an incident, but when I introduce the changes to sys close suddenly the OS encounters an error during booting, claiming it cannot mount root fs, and invokes panic. E...

Installing Linux Kernel Modules

I usually only work on the FreeBSD kernel and it is a bit different. I get up to the stage of making and installing the modules, but how do you actually boot the kernel that you just built? ...

Where has the the owner field of struct proc_dir_entry gone? [ Linux Kernel ]

According to the list of API changes in the 2.6 kernel series on LWN the .owner field of struct proc_dir_entry was removed in the 2.6.30 Kernel. So here's a couple of questions: Was it really ever necessary or useful to set this field? Has the field just been moved somewhere else, or permanently deleted? I ask the first question bec...

Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted software under Linux? I have read the work of van Doom et al., Design and implementation of signed executables for Linux, and the IBM's TL...