systems-programming

Is a process' page table mapped to Kernel address space?

独自空忆成欢 提交于 2021-02-05 09:38:18
问题 I was doing Windows system programming and wondered if I can access a process' page table on source code level. Here is what I know about page table related to virtual memory. Let's suppose an user just runs a process called 'A' process on Windows OS(32bit). First of all, the OS creates and maintains 4GB virtual address space for A process. (2GB of it is Kernel address space and the other 2GB is User address space. Any codes in User address space cannot directly access Kernel address space.)

Is a process' page table mapped to Kernel address space?

眉间皱痕 提交于 2021-02-05 09:37:28
问题 I was doing Windows system programming and wondered if I can access a process' page table on source code level. Here is what I know about page table related to virtual memory. Let's suppose an user just runs a process called 'A' process on Windows OS(32bit). First of all, the OS creates and maintains 4GB virtual address space for A process. (2GB of it is Kernel address space and the other 2GB is User address space. Any codes in User address space cannot directly access Kernel address space.)

What jobs OS does when we use mmap function?

隐身守侯 提交于 2021-01-29 22:20:41
问题 Here is a example that maps a given file to memory using mmap function. In this example, I didn't use fwrite or write function to write something into a disk file(just print contents to stdout), but the modified memory content is actually reflected on the disk file. I'm guessing that OS tracks mapped memory and writes to disk when mapped memory is modified. I'd like to know the detail of what OS does. example.c #include <stdio.h> #include <sys/mman.h> #include <stdlib.h> #include <sys/stat.h>

Create a chain of n sub processes

微笑、不失礼 提交于 2021-01-21 11:14:30
问题 In c++ create chain of n processes with n as input and the output of processes should be as parent1->child1(parent2)-->child2(parent3),by using recursive function im able to generate the output but unable to exit the loop i also need help in sending an input of n for which the loop should break. below is my code: #include <sys/types.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <sys/wait.h> int foo(const char *whoami) { printf("I am a %s. My pid is:%d my ppid is %d\n"

Create a chain of n sub processes

ぃ、小莉子 提交于 2021-01-21 11:13:43
问题 In c++ create chain of n processes with n as input and the output of processes should be as parent1->child1(parent2)-->child2(parent3),by using recursive function im able to generate the output but unable to exit the loop i also need help in sending an input of n for which the loop should break. below is my code: #include <sys/types.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <sys/wait.h> int foo(const char *whoami) { printf("I am a %s. My pid is:%d my ppid is %d\n"

mmap on /proc/pid/mem

和自甴很熟 提交于 2020-01-19 06:01:49
问题 Has anybody succeeded in mmap'ing a /proc/pid/mem file with Linux kernel 2.6? I am getting an ENODEV (No such device) error. My call looks like this: char * map = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, mem_fd, offset); And I have verified by looking at the /proc/pid/maps file while debugging that, when execution reaches this call, offset has the value of the top of the stack minus PAGE_SIZE. I have also verified with ptrace that mmap is setting errno to ENODEV. 回答1: See proc_mem

mmap on /proc/pid/mem

青春壹個敷衍的年華 提交于 2020-01-19 06:01:07
问题 Has anybody succeeded in mmap'ing a /proc/pid/mem file with Linux kernel 2.6? I am getting an ENODEV (No such device) error. My call looks like this: char * map = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, mem_fd, offset); And I have verified by looking at the /proc/pid/maps file while debugging that, when execution reaches this call, offset has the value of the top of the stack minus PAGE_SIZE. I have also verified with ptrace that mmap is setting errno to ENODEV. 回答1: See proc_mem

Do C and C++ standards imply that a special value in the address space must exist solely to represent the value of null pointers?

a 夏天 提交于 2020-01-11 14:26:31
问题 Following discussion from this question about null pointers in C and C++, I'd like to have the ending question separated here. If it can be inferred from C and C++ standards (answers can target both standards) that dereferencing a pointer variable whose value is equal to the nullptr (or (void *)0 ) value is undefined behavior, does it imply that these languages require that a special value in the address space is dead , meaning that it's unusable except for the role of representing nullptr ?