aboutsummaryrefslogtreecommitdiffstats
path: root/case-shm-lock-unlock
blob: dcbae1f4850acecde2290b8789d2f26803eb6ada (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh

#
# Exercises the SYS V IPC code of mm/
#
# Creates a shared segment using shmget, attaches and locks it
#
# to calling process's VM and then unlocks and releases it.
#

. ./hw_vars

#segment size being requested
SHM_SIZE=$((shm_size / nr_task / 2))

#check for max shared memory allowed on system
MAX_SHARE_SEGMENT=$(cat /proc/sys/kernel/shmmax)

echo "MAX SEGMENT is $MAX_SHARE_SEGMENT total asking is $((shm_size / 2))"

#check to see if the request can be satisfied else exit with error
if [ $MAX_SHARE_SEGMENT -lt $SHM_SIZE ]
then
	echo "Cannot allocate more shared memory segment than $MAX_SHARE_SEGMENT"
	echo "exiting now..."
	exit 1 #exit on failure
fi

$USEMEM -n $nr_task -L --random $SHM_SIZE