- Mastering Linux Kernel Development
- Raghu Bharadwaj
- 257字
- 2021-07-08 09:47:16
Process limits - key elements
The kernel imposes resource limits to ensure fair allocation of system resources among contending processes. These limits guarantee that a random process does not monopolize ownership of resources. There are 16 different types of resource limits, and the task structure points to an array of type struct rlimit, in which each offset holds the current and maximum values for a specific resource.
/*include/uapi/linux/resource.h*/
struct rlimit {
__kernel_ulong_t rlim_cur;
__kernel_ulong_t rlim_max;
};
These limits are specified in include/uapi/asm-generic/resource.h
#define RLIMIT_CPU 0 /* CPU time in sec */
#define RLIMIT_FSIZE 1 /* Maximum filesize */
#define RLIMIT_DATA 2 /* max data size */
#define RLIMIT_STACK 3 /* max stack size */
#define RLIMIT_CORE 4 /* max core file size */
#ifndef RLIMIT_RSS
# define RLIMIT_RSS 5 /* max resident set size */
#endif
#ifndef RLIMIT_NPROC
# define RLIMIT_NPROC 6 /* max number of processes */
#endif
#ifndef RLIMIT_NOFILE
# define RLIMIT_NOFILE 7 /* max number of open files */
#endif
#ifndef RLIMIT_MEMLOCK
# define RLIMIT_MEMLOCK 8 /* max locked-in-memory
address space */
#endif
#ifndef RLIMIT_AS
# define RLIMIT_AS 9 /* address space limit */
#endif
#define RLIMIT_LOCKS 10 /* maximum file locks held */
#define RLIMIT_SIGPENDING 11 /* max number of pending signals */
#define RLIMIT_MSGQUEUE 12 /* maximum bytes in POSIX mqueues */
#define RLIMIT_NICE 13 /* max nice prio allowed to
raise to 0-39 for nice level 19 .. -20 */
#define RLIMIT_RTPRIO 14 /* maximum realtime priority */
#define RLIMIT_RTTIME 15 /* timeout for RT tasks in us */
#define RLIM_NLIMITS 16
推薦閱讀
- Scratch 3.0少兒編程與邏輯思維訓練
- HTML5 and CSS3 Transition,Transformation,and Animation
- 琢石成器:Windows環(huán)境下32位匯編語言程序設計
- 焊接機器人系統(tǒng)操作、編程與維護
- 零基礎入門學習Python(第2版)
- Learning jQuery(Fourth Edition)
- Mastering Git
- Python 3.7從入門到精通(視頻教學版)
- Python入門很輕松(微課超值版)
- Hands-On Neural Network Programming with C#
- Java Web從入門到精通(第3版)
- Photoshop CC移動UI設計案例教程(全彩慕課版·第2版)
- 嵌入式Linux C語言程序設計基礎教程
- 量子計算機編程:從入門到實踐
- HTML5+CSS3+jQuery Mobile+Bootstrap開發(fā)APP從入門到精通(視頻教學版)