Resource Library Python:
This module in python provides basic mechanisms for measuring and controlling system resources utilized by a program. And the symbolic constants are used to specify particular system resources and to request usage information about either the current process or its children. If there is a syscall failure, the OSError is raised.
As stated in my previous article, some more symbolic constants related to resource limits are defined below:
This gives the largest of the mapped memory which the process may occupy.
This gives the maximum area in bytes of the address space which may be taken by the process.
This gives the number of bytes that can be allotted for the POSIX Message Queues.
POSIX message queues are the means by which the processes exchange data in the form of messages to accomplish their tasks. They enable the processes to synchronise their reads and writes to speed up processes.
The ceiling of the nice level of a process.
The priority of the process is often called the nice vale of the process. The range of the nice value of these processes are generally from -20 to 20 on most Unix like operating systems. Nice value controls the CPU time assigned to the process and not the utilization of memory and I/O devices.
This gives the ceiling of the real-time priority.
Real-Time priority is the highest priority class available to a process. It is used to manage the real time device operations mostly in kernel mode. For example: Mouse or Keyboard inputs may be set on real time as code for such device extends Real Time Priority.
This gives the time limit in microseconds on CPU time that a process can spend under real time scheduling without making a blocking syscall.
This gives the number of signals which the process may queue.
A signal is a notification to a process that an event has occurred. Signals are sometimes described as software interrupts, because in most cases, they interrupt the normal flow of execution of a program and their arrival is unpredictable. It can be sent by Kernel or a Process.
After a signal is generated due to some event, it does not directly get delivered to a process, and the signal remains in an intermediate state called to a pending state. To ensure that a signal does not arrive during execution of some critical section, a process can add signal to its process’s signal mask, which is a set of signals whose delivery is currently blocked. Process’s signal mask is a per process attribute. If a signal is generated when it is blocked, it remains in pending state until later it is unblocked.
The socket buffer is the structure used to address and manage a packet over the entire time this packet is being processed in the kernel. When an application passes data to a socket, then the socket creates an appropriate socket buffer structure and stores the payload data address in the variables of this structure.
This gives the maximum size in bytes of the socket buffer usage for this user. This limits the amount of the network memory, and hence the amount of mbufs, that this user may hold at any time.
This gives the maximum size in bytes of the swap space that may be reserved of used by all of its user's id's processes. And this limit is enforced bit 1 of the vm.overcommit is set.
Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in the memory are moved to the swap space. While the swap space can help machines with a small amount of RAM, it should not be considered a replacement for RAM.
this return the maximum amount of pseudo terminals in the system
This gives the maximum number of Kqueues this user is allowed to create.
Kqueue is a scalable event notification interface and it provides efficient input and output event pipelines between the kernel and userland. Kqueue not only handles file descriptor events but is also used for various other notifications such as file modification monitoring, signals, asynchronous I/O events (AIO), child process state change monitoring, and timers which support nanosecond resolution, furthermore kqueue provides a way to use user-defined events in addition to the ones provided by the kernel.