kernel

Will the functions and variables precede with an “_” when compiled using gcc?

谁说我不能喝 提交于 2020-06-08 05:52:48
问题 I am learning OS development in a Linux environment using GCC. I learnt in Bran's Kernel Development that all the functions and variable names in C when compiled precedes with an "_"(underscore) in its corresponding Assembly source file. But when I went through the assembly source of a compiled C program, I can't even find the "_main" function. I performed the following. cpp sample.c sample.i gcc -S sample.I 回答1: That was true in the early days. A given C function foo would show up as _foo in

What happens when you lose the virtual address of the page directory?

流过昼夜 提交于 2020-06-01 01:40:29
问题 I'm writing a memory manager for my kernel (32 bit x86) In the course of this... I'm facing a bit of a dilemma.... Description of virtual memory map: Identity map of first 4 Mb Virtual address 0xC0000000 mapped to physical address 0x100000 (Also a 4 Mb map) My page directory is at physical address 0x9c000. My page table 1 is at physical address 0x9d000. My page table 2 is at physical addres 0x9e000. (I need only two page tables here :) ... These correspond to the identity map and higher

What happens when you lose the virtual address of the page directory?

限于喜欢 提交于 2020-06-01 01:38:08
问题 I'm writing a memory manager for my kernel (32 bit x86) In the course of this... I'm facing a bit of a dilemma.... Description of virtual memory map: Identity map of first 4 Mb Virtual address 0xC0000000 mapped to physical address 0x100000 (Also a 4 Mb map) My page directory is at physical address 0x9c000. My page table 1 is at physical address 0x9d000. My page table 2 is at physical addres 0x9e000. (I need only two page tables here :) ... These correspond to the identity map and higher

after using rmmod program freezes

徘徊边缘 提交于 2020-05-17 07:44:05
问题 I have some problem with my code. In my code i solve the reader writers problem using RCU, when i load the module (insmod) everything works ok, and it works as i expected, but when i unload module (rmmod) my program freezes and I have to restart Ubuntu. In this program i have to use call_rcu() to delete previous version of the shared resource and i think that problem is here, because if i have not if I do not use this function and simply delete via kmalloc () then the program works as it

linux kernel page table update

|▌冷眼眸甩不掉的悲伤 提交于 2020-05-16 13:27:55
问题 In linux x86 paging. each process has it's own page directory. page table walking starts with page directory which is pointed by CR3. every process shares the kernel page directory content assuming three sentences are correct, let's say some process enters kernel mode and updates his kernel page directory content(address mapping, access rights, etc...) Question. since kernel address spaces is globally shared among processes, this update has to be synchronized with other process's page

Is it possible that linux file descriptor 0 1 2 not for stdin, stdout and stderr?

Deadly 提交于 2020-05-12 12:07:09
问题 When a program begins, does it take file descriptors 0, 1 and 2 for stdin, stdout and stderr by default?. And will API calls such as open(...), socket(...) not return 0, 1 and 2 since these values are already taken?. Is there any case in which open(...) or socket(...) would return 0, 1 or 2. And 0, 1 and 2 are not related with stdin, stdout, and stderr. 回答1: At the file descriptor level, stdin is defined to be file descriptor 0 , stdout is defined to be file descriptor 1 ; and stderr is

How to get process name from PID using C

我的梦境 提交于 2020-05-12 08:00:39
问题 I want to get the process name from task_struct , but I get an error dereferencing pointer to incomplete type (task->comm). I have to use pid_task function. I have no idea why it does not work. ssize_t simple_read(struct file *filp, char __user *user_buf, size_t count, loff_t *f_pos) { int len=0; pid_struct = find_get_pid(pid); task = pid_task(pid_struct,PIDTYPE_PID); len = sprintf(user_buf,"\nname %s\n ",task->comm); return len; } 回答1: To find the task_struct of a process we can make use of

What is kthreadd process and children and how it is different from init and children

為{幸葍}努か 提交于 2020-05-09 19:01:08
问题 I wanted to know what is kthread and why it does not take any memory and has no open files. I wrote some code which will simply print the PID of the currently running processes in a parent child tree format along with some additional information like used VMZ, RSS, threads, openfiles. All the children of the PID 2 named kthreadd did not have the VmSize and VmRSS in the /proc/[pid]/status file. the /proc/[pid]/fd did not contain any open files. What are these processes, how they are different

AF_XDP: No packets for socket with queue-id 0 even though every packet is redirect

試著忘記壹切 提交于 2020-04-18 05:43:15
问题 I am based on this tutorial: https://github.com/xdp-project/xdp-tutorial/tree/master/advanced03-AF_XDP I create a socket with Queue-ID 0 in userspace. In my kernel af-xdp program I filter for UDP-packets and redirect them to the userspace socket via a xskmap . Because I obviously want the userspace-program to receive packets, I redirect the packets in the kernel program to index 0 : int index = 0; if (bpf_map_lookup_elem(&xsks_map, &index)) { return bpf_redirect_map(&xsks_map, index, 0); }