zoukankan
html css js c++ java
linux显示shm segment信息一例
#include <stdio.h> #include <sys/shm.h> #include <sys/stat.h> int main(void) { int segment_id; char* shared_memory; const int size = 4096; unsigned short mode; struct shmid_ds shmbuffer; segment_id = shmget(IPC_PRIVATE, size, S_IRUSR|S_IWUSR); shared_memory = (char*)shmat(segment_id, NULL, 0); sprintf(shared_memory, "shared memory"); printf("%s\n", shared_memory); if (shmctl(segment_id, IPC_STAT, &shmbuffer) == - 1) { fprintf(stderr, "Unable to access segment %d\n", segment_id); return -1; } printf("ID \t\t KEY \t MODE \t\t OWNER \t SIZE \t ATTTACHES \n"); printf("-- \t\t --- \t ---- \t\t ----- \t ---- \t --------- \n"); printf("%d \t %d \t",segment_id,shmbuffer.shm_perm.__key); mode = shmbuffer.shm_perm.mode; /** OWNER */ if (mode & 0400) printf("r"); else printf("-"); if (mode & 0200) printf("w"); else printf("-"); if (mode & 0100) printf("a"); else printf("-"); /** GROUP */ if (mode & 0040) printf("r"); else printf("-"); if (mode & 0020) printf("w"); else printf("-"); if (mode & 0010) printf("a"); else printf("-"); /** WORLD */ if (mode & 0004) printf("r"); else printf("-"); if (mode & 0002) printf("w"); else printf("-"); if (mode & 0001) printf("a"); else printf("-"); printf(" \t%4d\t",shmbuffer.shm_perm.uid); printf(" %d\t",shmbuffer.shm_segsz); printf(" %d\t",shmbuffer.shm_nattch); printf("\n%d", mode); printf("\n"); shmdt(shared_memory); shmctl(segment_id, IPC_RMID, NULL); fprintf(stdout, "\n%d", segment_id); return 0; }
查看全文
相关阅读:
Codeforces Round #324 (Div. 2) D. Dima and Lisa 哥德巴赫猜想
Codeforces Round #324 (Div. 2) C. Marina and Vasya 贪心
Codeforces Round #324 (Div. 2) B. Kolya and Tanya 快速幂
Codeforces Round #324 (Div. 2) A. Olesya and Rodion 水题
使用spring-loaded实现应用热部署
maven中properties标签定义变量
java中的匿名内部类总结
泛型类型限定和通配符类型限定
基于ActiveMQ的Topic的数据同步——消费者持久化
基于ActiveMQ的Topic的数据同步——初步实现
原文地址:https://www.cnblogs.com/seebro/p/2476556.html
最新文章
Codeforces Round #326 (Div. 2) A. Duff and Meat 水题
HDU 4819 Mosaic 二维线段树
HDU 4821 String hash
HDU 4813 Hard Code 水题
ZOJ 3633 Alice's present 倍增 区间查询最大值
Codeforces Round #325 (Div. 2) F. Lizard Era: Beginning meet in the mid
Codeforces Round #325 (Div. 2) D. Phillip and Trains BFS
Codeforces Round #325 (Div. 2) C. Gennady the Dentist 暴力
Codeforces Round #325 (Div. 2) A. Alena's Schedule 水题
Codeforces Round #325 (Div. 2) B. Laurenty and Shop 前缀和
热门文章
Codeforces Round #200 (Div. 1)D. Water Tree dfs序
Codeforces Round #200 (Div. 1) C. Read Time 二分
HDU 5501 The Highest Mark 背包dp
HDU 5500 Reorder the Books 贪心
Codeforces Round #200 (Div. 1) B. Alternating Current 栈
Codeforces Round #200 (Div. 1)A. Rational Resistance 数学
BZOJ 1143: [CTSC2008]祭祀river 最长反链
VK Cup 2015
BZOJ 4291: [PA2015]Kieszonkowe 水题
Codeforces Round #324 (Div. 2) E. Anton and Ira 贪心
Copyright © 2011-2022 走看看