Play with Solaris project

In this short article I will demonstrate few options of project subsystem in Solaris.
1. Create sample project
# projadd -p 101 -c "my first project" -K "process.max-data-size=(priv,32m,deny)" test1

where 101 is the ID (numeric) of the project
"my first project" is just a comment
test1 is the name of the project
and "process.max-data-size=(priv,32m,deny)" describe attributes. In this example i limit memory data segment to 32 megabytes. The string "priv" is definition who can modify the value and string "deny" define the action when the value is reached.For more info see manual page of resource_controls(5)

2. Check the project
# projects -l
system
        projid : 0
        comment: ""
        users  : (none)
        groups : (none)
        attribs:
...
test1
        projid : 101
        comment: "my first project"
        users  : (none)
        groups : (none)
        attribs: process.max-data-size=(priv,33554432,deny)

3. Test if its work
For this purpose I will use one sample C program to allocate memory and exec it

# newtask -p test1 ./a.out
allocated 2 bytes
allocated 4 bytes
allocated 8 bytes
allocated 16 bytes
allocated 32 bytes
allocated 64 bytes
...
allocated 4194304 bytes
allocated 8388608 bytes
allocated 16777216 bytes

and just in case check exit code :)
# echo $?
1

4. Modify the project to give more memory
projmod -p 101 -K "process.max-data-size=(priv,64m,deny)" test1

5. and check again
# newtask -p test1 ./a.out
allocated 2 bytes
allocated 4 bytes
allocated 8 bytes
allocated 16 bytes
allocated 32 bytes
allocated 64 bytes
...
allocated 4194304 bytes
allocated 8388608 bytes
allocated 16777216 bytes
allocated 33554432 bytes

As you can see all work perfect and we can start using projects in our daily work

No comments:

Post a Comment

Compressed tar archive

There are some cases when you want to create compressed tar archive but you do not have enough disk space to keep original files and tar arc...