Download presentation
Presentation is loading. Please wait.
Published byIsabella Evans Modified over 6 years ago
1
Exercise 6 from Gary Nutt’s Kernel Projects for Linux
Joe Malta Kris Wright John Bird Jason Gallick Tom Fortmuller
2
Overview of Presentation
Review shared memory Explain the steps we took to complete our project Discuss the problems we encountered
3
Shared Memory Basics Part of InterProcess Communication (IPC) mechanism Developed so that processes could easily communicate with each other and work together Each process is allocated a certain amount of virtual memory when created, but only a small part of this is initially used. The rest can be used to hold data.
4
Shared Memory Basics (con’t)
A block of main memory may be defined as a block of shared memory Any process may map the block of shared memory to its own virtual address space Processes communicate by reading from and writing to the shared memory block. When one process changes information in the shared block of memory, all processes have access to the changed data. Segments of program code that change data in shared memory is called the critical section
5
Shared Memory Basics (con’t)
6
Project Implementation
Understanding the Project requirements
7
Project Implementation (con’t)
Understanding the Project requirements Learning methods of shm.c
8
Functions of Shm.c Manages the shared memory of Linux
Important functions: find_key, newseg, shm_get, shm_init Array based
9
Shm.c Variables and more about Shm_get
SHMNI and SHMALL are constants, IPC_UNUSED and IPC_NOID are flags Shm_get could be the most important function in shm.c Heavily dependant on newseg and find_key
10
Project Implementation (con’t)
Understanding the Project requirements Learning methods of shm.c Developing a program to test shared memory
11
Importance of Test Program
Showed how shared memory works on a Linux machine Made sure that shared memory was being recycled Proved that linked list was functioning properly Compared results from array based shm.c file and linked list shm.c file
12
Project Implementation (con’t)
Understanding the Project requirements Learning methods of shm.c Developing a program to test shared memory Changing shm.c from array to linked list
13
Modifying the Shm.c File
Additions required struct shm_list Pointer to next element in list Pointer to shared memory data structure struct shmid_kernel *findseg(int id) Returns idth shared memory struct in list int newshm(void) Appends a new node to the end of list void setseg(int id,struct shmid_kernel *value) Sets idth shared memory struct in list to value
14
Modifying the Shm.c File (con’t)
List Initialization Create head of list Original code replacement Replace variable = shm_segs[x] statements with variable = findseg(x) Replace shm_segs[x] = value with setseg(x,value)
15
Project Implementation (con’t)
Understanding the Project requirements Learning methods of shm.c Developing a program to test shared memory Changing shm.c from array to linked list Compiling shm.c
16
Problems - Compiling To properly compile the kernel the following environment variables must be passed to gcc <gcc –D__KERNEL__ -I/user/src/linux/include –Wall –Wstrict-prototypes –02 –fomit-frame -pointer –fno-strict -aliasing –pipe –03 –fomit-frame-pointer –fno-exceptions –fno -rtti –pipe –s –mpentium –mcpu=pentium –march=pentium –ffast-math –fexpensive optimizations -m486 –malign-loops=2 –malign-jumps=2 –malign-functions=2 –DCPU=586 -c –o shm.o shm.c> These variables were found by redirecting outputting from make to a text file, and GREPing the text file for shm.c
17
Problems (con’t) - Kernel
We were working on a Linux Red Hat 9 machine, kernel version Gary Nutt’s text refers to Linux Mandrake 7, kernel version The two versions are considerably different. We installed Mandrake 7, kernel version 2.2, which is current with Gary Nutt’s Kernel Projects for Linux
18
End
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.