sysv-ipc

What stops me from reading/writing further than the size of a shared memory? (System V IPC)

无人久伴 提交于 2019-12-24 10:49:34
问题 What I'm doing is: shmget(shm_key, shm_size, 0666 | IPC_CREAT); (and of course attach to it) and I've already set the size to exactly 12 Bytes but when i try something like: sprintf(shm_ptr, "Imagine about 200-300 characters here\n"); it seems to work normally with zero problems or warnings, and to check that , I tried to read it from a completely different process (i fork and exec the first one) and sure enough printf("%s", shm_ptr); prints the message that was in that segment, which is

sys v shared memory from kernel module to user space process

蓝咒 提交于 2019-12-13 07:18:14
问题 i am new in linux kernel module developpement and i am searching for sharing a memory segment from kernel module to user space process to escape latency of copying data. i am using the sys v shared memory api, when i share memory between two process it's work fine, but i am not able to share memory between process and kernel module. bellow is my code of the kernel module and the user space app server side : module #include <linux/module.h> // init_module, cleanup_module // #include <linux

System V shared memory permission bits: meaning, and how to change

妖精的绣舞 提交于 2019-12-13 01:23:21
问题 I know that when i create a shared memory block, we set the permission so that every proccess can read and write in that block with 0777 (no idea why, my teacher just said to use it like that). I'm creating with shmget as: shmget(IPC_PRIVATE, sizeof(server_config), IPC_CREAT|0777) However I'd like to know: What each number means How to change the flag after the shared memory block is created How to only allow 1 proccess to write, while all the other proccesses can only read 回答1: It's an octal