Get link Facebook X Pinterest Email Other Apps November 26, 2024 https://forms.gle/m65HWUV5WCTMeUJS8 Get link Facebook X Pinterest Email Other Apps Comments
Start system call October 16, 2024 #include <stdio.h> #include <sys/stat.h> #include <stdlib.h> #include <time.h> int main(int argc, char* argv[]) { struct stat file; int n; if (argc != 2) { printf("Usage: ./a.out <filename>\n"); exit(-1); } // Checking if file statistics can be obtained if ((n = stat(argv[1], &file)) == -1) { perror(argv[1]); exit(-1); } // Printing file information printf("User id: %d\n", file.st_uid); printf("Group id: %d\n", file.st_gid); printf("Block size: %ld\n", file.st_blksize); printf("Blocks allocated: %ld\n", file.st_blocks); printf("Inode no.: %ld\n", file.st_ino); printf("Last accessed: %s", ctime(&(file.st_atime))); printf("Last m... Read more
Implementation October 29, 2024 2. Implementation of Shared Memory and IPC Program: Server /* Shared memory server - shms.c */ #include <stdio.h> #include <stdlib.h> #include <sys/un.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> #define shmsize 27main() { char c; int shmid; key_t key =2013;char *shm, *s; if ((shmid = shmget(key, shmsize, IPC_CREAT|0666)) < 0) { perror("shmget");exit(1); } printf("Shared memory id : %d\n", shmid); if ((shm = shmat(shmid, NULL, 0)) == (char *) -1) { perror("shmat");exit(1); } memset(shm, 0, shmsize);s = shm; printf("Writing (a-z) onto shared memory\n");for (c = 'a'; c <= 'z'; c++) *s++ = c; *s = '\0'; while (*shm != '*'); printf("Client finished reading\n"); if(shmdt(shm) != 0) fprintf(stderr, "Could not close memory segment.\n"); shmctl(shmid, IPC_RMID, 0); } Client /* Shared memory client - shmc.c */ #include <stdio.h> #inc... Read more
Comments
Post a Comment