This presentation covers the understanding of system calls for various resource management and covers system calls for file management in details. The understanding of using system calls helps to start with working with device driver programming on Unix/Linux OS.
Gives an overview about Process, PCB, Process States, Process Operations, Scheduling, Schedulers, Interprocess communication, shared memory and message passing systems
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURESpriyasoundar
These slides will help the engineering students for understanding the functionalities of operating system and its structure. Also it will help them for their exam preparation.
Quontra Solutions offers Job oriented Linux online training with updated technologies. For more info about our Linux online training contact us directly. We are providing Linux online training to all students throughout worldwide by real time faculties. Our Linux training strengthens your skills and knowledge which will helps you to gain a competitive advantage in starting your career. Outclasses will help you to gain knowledge on real time scenario. It will be most use full to boost up your career.
Our training sessions are designed in such a way that all the students can be convenient with the training schedules and course timings.
Along with Training, we also conduct several mock interviews along with Job Placement Assistance. Attend Free Demo before joining the class.
Our Features:
• Real world projects to get practical based experience
• Online tests to explore the resource learning
• Experienced certified trainers as instructors
• One to one personalized training with desktop access
• Case studies and state of art library to access study material
• Resume build assistance to win in interviews
Contact us:
Simson Andrew
Email: info@quontrasolutions.com
web: www.quontrasolutions.com
In the given presentation, process overview,process management scheduling typesand some more basic concepts were explained.
Kindly refere the presentation.
Operating system 02 os as an extended machineVaibhav Khanna
Functions performed by the
operating systems:
Managing the hardware resources of the
computer
Providing the user-interface components
Providing a platform for software developers
to write applications
Operating Systems Process Scheduling Algorithmssathish sak
CPU scheduling big area of research in early ‘70s
Many implicit assumptions for CPU scheduling:
One program per user
One thread per program
Programs are independent
These are unrealistic but simplify the problem
Does “fair” mean fairness among users or programs?
If I run one compilation job and you run five, do you get five times as much CPU?
Often times, yes!
Goal: dole out CPU time to optimize some desired parameters of the system.
A short explanation of Architecture of operating system. In this slide i explain about monolithic OS , layer OS, microkernel OS and networked and distributed OS with their architecture.
Advanced Operating System- IntroductionDebasis Das
Introduction to Advanced Operating systems. Many university courses run advanced/ distributed operating system courses in their 4 year engineering programs. This is based on WBUT CS 704 D course but matches many such courses run by different universities. If you need to downloaad this presentation, please send me an email at ddas15847@gmail.com
operating system calls input and output by (rohit malav)Rohit malav
Introduction of System Call
In computing, a system call is the programmatic way in which a computer program requests a service from the kernel of the operating system it is executed on. A system call is a way for programs to interact with the operating system. A computer program makes a system call when it makes a request to the operating system’s kernel. System call provides the services of the operating system to the user programs via Application Program Interface(API). It provides an interface between a process and operating system to allow user-level processes to request services of the operating system. System calls are the only entry points into the kernel system. All programs needing resources must use system calls.
Services Provided by System Calls :
Process creation and management
Main memory management
File Access, Directory and File system management
Device handling(I/O)
Protection
Networking, etc.
Gives an overview about Process, PCB, Process States, Process Operations, Scheduling, Schedulers, Interprocess communication, shared memory and message passing systems
OPERATING SYSTEM SERVICES, OPERATING SYSTEM STRUCTURESpriyasoundar
These slides will help the engineering students for understanding the functionalities of operating system and its structure. Also it will help them for their exam preparation.
Quontra Solutions offers Job oriented Linux online training with updated technologies. For more info about our Linux online training contact us directly. We are providing Linux online training to all students throughout worldwide by real time faculties. Our Linux training strengthens your skills and knowledge which will helps you to gain a competitive advantage in starting your career. Outclasses will help you to gain knowledge on real time scenario. It will be most use full to boost up your career.
Our training sessions are designed in such a way that all the students can be convenient with the training schedules and course timings.
Along with Training, we also conduct several mock interviews along with Job Placement Assistance. Attend Free Demo before joining the class.
Our Features:
• Real world projects to get practical based experience
• Online tests to explore the resource learning
• Experienced certified trainers as instructors
• One to one personalized training with desktop access
• Case studies and state of art library to access study material
• Resume build assistance to win in interviews
Contact us:
Simson Andrew
Email: info@quontrasolutions.com
web: www.quontrasolutions.com
In the given presentation, process overview,process management scheduling typesand some more basic concepts were explained.
Kindly refere the presentation.
Operating system 02 os as an extended machineVaibhav Khanna
Functions performed by the
operating systems:
Managing the hardware resources of the
computer
Providing the user-interface components
Providing a platform for software developers
to write applications
Operating Systems Process Scheduling Algorithmssathish sak
CPU scheduling big area of research in early ‘70s
Many implicit assumptions for CPU scheduling:
One program per user
One thread per program
Programs are independent
These are unrealistic but simplify the problem
Does “fair” mean fairness among users or programs?
If I run one compilation job and you run five, do you get five times as much CPU?
Often times, yes!
Goal: dole out CPU time to optimize some desired parameters of the system.
A short explanation of Architecture of operating system. In this slide i explain about monolithic OS , layer OS, microkernel OS and networked and distributed OS with their architecture.
Advanced Operating System- IntroductionDebasis Das
Introduction to Advanced Operating systems. Many university courses run advanced/ distributed operating system courses in their 4 year engineering programs. This is based on WBUT CS 704 D course but matches many such courses run by different universities. If you need to downloaad this presentation, please send me an email at ddas15847@gmail.com
operating system calls input and output by (rohit malav)Rohit malav
Introduction of System Call
In computing, a system call is the programmatic way in which a computer program requests a service from the kernel of the operating system it is executed on. A system call is a way for programs to interact with the operating system. A computer program makes a system call when it makes a request to the operating system’s kernel. System call provides the services of the operating system to the user programs via Application Program Interface(API). It provides an interface between a process and operating system to allow user-level processes to request services of the operating system. System calls are the only entry points into the kernel system. All programs needing resources must use system calls.
Services Provided by System Calls :
Process creation and management
Main memory management
File Access, Directory and File system management
Device handling(I/O)
Protection
Networking, etc.
The objectives of these slides are:
- To describe the services an operating system provides to users, processes, and other systems
- To discuss the various ways of structuring an operating system
- To explain how operating systems are installed and customized and how they boot
Operating System definitions and about system calls
Operating System Services
User and Operating System-Interface
System Calls
Types of system calls
System Programs
Student information management system project report ii.pdfKamal Acharya
Our project explains about the student management. This project mainly explains the various actions related to student details. This project shows some ease in adding, editing and deleting the student details. It also provides a less time consuming process for viewing, adding, editing and deleting the marks of the students.
Forklift Classes Overview by Intella PartsIntella Parts
Discover the different forklift classes and their specific applications. Learn how to choose the right forklift for your needs to ensure safety, efficiency, and compliance in your operations.
For more technical information, visit our website https://intellaparts.com
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
CFD analysis is incredibly effective at solving mysteries and improving the performance of complex systems!
Here's a great example: At a large natural gas-fired power plant, where they use waste heat to generate steam and energy, they were puzzled that their boiler wasn't producing as much steam as expected.
R&R and Tetra Engineering Group Inc. were asked to solve the issue with reduced steam production.
An inspection had shown that a significant amount of hot flue gas was bypassing the boiler tubes, where the heat was supposed to be transferred.
R&R Consult conducted a CFD analysis, which revealed that 6.3% of the flue gas was bypassing the boiler tubes without transferring heat. The analysis also showed that the flue gas was instead being directed along the sides of the boiler and between the modules that were supposed to capture the heat. This was the cause of the reduced performance.
Based on our results, Tetra Engineering installed covering plates to reduce the bypass flow. This improved the boiler's performance and increased electricity production.
It is always satisfying when we can help solve complex challenges like this. Do your systems also need a check-up or optimization? Give us a call!
Work done in cooperation with James Malloy and David Moelling from Tetra Engineering.
More examples of our work https://www.r-r-consult.dk/en/cases-en/
Event Management System Vb Net Project Report.pdfKamal Acharya
In present era, the scopes of information technology growing with a very fast .We do not see any are untouched from this industry. The scope of information technology has become wider includes: Business and industry. Household Business, Communication, Education, Entertainment, Science, Medicine, Engineering, Distance Learning, Weather Forecasting. Carrier Searching and so on.
My project named “Event Management System” is software that store and maintained all events coordinated in college. It also helpful to print related reports. My project will help to record the events coordinated by faculties with their Name, Event subject, date & details in an efficient & effective ways.
In my system we have to make a system by which a user can record all events coordinated by a particular faculty. In our proposed system some more featured are added which differs it from the existing system such as security.
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Dr.Costas Sachpazis
Terzaghi's soil bearing capacity theory, developed by Karl Terzaghi, is a fundamental principle in geotechnical engineering used to determine the bearing capacity of shallow foundations. This theory provides a method to calculate the ultimate bearing capacity of soil, which is the maximum load per unit area that the soil can support without undergoing shear failure. The Calculation HTML Code included.
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfKamal Acharya
The College Bus Management system is completely developed by Visual Basic .NET Version. The application is connect with most secured database language MS SQL Server. The application is develop by using best combination of front-end and back-end languages. The application is totally design like flat user interface. This flat user interface is more attractive user interface in 2017. The application is gives more important to the system functionality. The application is to manage the student’s details, driver’s details, bus details, bus route details, bus fees details and more. The application has only one unit for admin. The admin can manage the entire application. The admin can login into the application by using username and password of the admin. The application is develop for big and small colleges. It is more user friendly for non-computer person. Even they can easily learn how to manage the application within hours. The application is more secure by the admin. The system will give an effective output for the VB.Net and SQL Server given as input to the system. The compiled java program given as input to the system, after scanning the program will generate different reports. The application generates the report for users. The admin can view and download the report of the data. The application deliver the excel format reports. Because, excel formatted reports is very easy to understand the income and expense of the college bus. This application is mainly develop for windows operating system users. In 2017, 73% of people enterprises are using windows operating system. So the application will easily install for all the windows operating system users. The application-developed size is very low. The application consumes very low space in disk. Therefore, the user can allocate very minimum local disk space for this application.
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...Amil Baba Dawood bangali
Contact with Dawood Bhai Just call on +92322-6382012 and we'll help you. We'll solve all your problems within 12 to 24 hours and with 101% guarantee and with astrology systematic. If you want to take any personal or professional advice then also you can call us on +92322-6382012 , ONLINE LOVE PROBLEM & Other all types of Daily Life Problem's.Then CALL or WHATSAPP us on +92322-6382012 and Get all these problems solutions here by Amil Baba DAWOOD BANGALI
#vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore#blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #blackmagicforlove #blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #Amilbabainuk #amilbabainspain #amilbabaindubai #Amilbabainnorway #amilbabainkrachi #amilbabainlahore #amilbabaingujranwalan #amilbabainislamabad
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Introduction to System Calls
1. Introduction to System calls
• Objectives
• Understanding system calls
• System calls and library functions
• Interfacing functions between user space and kernel space
• Types of system calls
• File management
• Process management
• Device management
• Information and maintenance
• Process communication
• Programs implementing system calls
2. Operating system services
• An Operating system provides an environment for the execution of
programs.
• It provides set of services to programs and to users of those programs.
• One set of services provides functions that are helpful to the user
– User interface
– Program execution
– I/O operations
– File system manipulations
– Communications
– Error detection
• Another set of services exists not for helping the user but rather for
ensuring the efficient operation of the system itself.
– Resource allocation
– Accounting
– Protection and security
3. User related services
• User interface
– Almost all OS have a user interface (UI)
– These can Command line interface (CLI), Batch (in which commands are entered in files)
and Graphical user interface (GUI)
• Program execution
– The system must be able to load the program in memory and execute.
• I/O operation
– A running program may require I/O, which may involve a file and an I/O device.
– For efficiency and protection purpose , users cannot control I/O devices directly.
– OS must provides means to do I/O
• File system manipulations
– Programs needs to read and write files and directories
– Also create, delete, search and list files
– Permission management to allow or deny access to files and directories
4. • Communication
– Communication between process executing on same computer or
between processes that are executing on different computer systems
tied together by computer networks
– Communication can be implemented via “shared memory” or through
“message passing” in which case packets of information moves
between processes by the OS.
• Error detection
– OS needs to be constantly aware of possible errors. Errors may occur
• In CPU or memory hardware (such as memory error or power
failure),
• In I/O devices (lack of paper in printer or connection failure on
network)
• In User programs (arithmetic over flow or an attempt to access an
illegal memory location)
5. System related services
• Resource allocation
– When there are multiple users running at the same time, resources
must be allocated to each of them.
– Many different types of resources are managed by the OS such as
• Main memory
• File storage
• CPU cycles
• Accounting
– Keeping track of users activity and resource allocation and utilization
– Usage statistics may be valuable tool for researchers who wish to
reconfigure the system to improve computing services
6. System related services
• Protection and security
– When several processes execute concurrently, it not be possible for
one process to interfere with the others or with the operating system
itself.
– Protection involves ensuring that all access to system resources is
controlled
– Security of the system from the outsiders is also important
– Such security starts with requiring each user to authenticate himself
or herself to the system, usually by means of password to gain access
to the system resources.
7. User operating system interface
• Two approaches for users to interface with the operating system
– Command line interface (CLI) or command interpreter
– Graphical user interface (GUI)
• Command line interface or command interpreters
– Command interpreters on Linux are special programs that the program is initiated or
when the user first logs in.
– On systems with multiple command interpreters to choose from, the interpreters are
known as ‘shells’
– On Linux systems, there are several different shells a user may choose from, including
Bourne shell, C shell, Korn shell
– Most shell provides similar functionality with minor differences
– The main function of the command interpreter is to get and execute the next user-
specific command.
8. Graphical user interface
• GUI provides a mouse based, window-and-menu system as an interface
• A GUI provides a desktop metaphor where the mouse is moved to
position its pointer moves.
• Depending on the mouse pointer’s location, clicking a button on the
mouse can invoke a program, select a file or directory
• X-Windows systems is GUI example on Linux systems
• On Linux systems there are various open source projects
– K desktop environment (KDE)
– GNOME desktop
9. System calls
• All operating systems provides some mechanism to request services from
the kernel.
• This service request points are called “system calls”
• In Linux system, there is an interface layer between the user space and
kernel space. This layer consists of library made up of functions that
communicate between normal user applications and the Kernel.
• This implementation of C library is called libc/glibc. This provides wrapper
functions for the system calls.
• System calls are implemented using software interrupt or trap.
• System call transfer control to the operating system. It sets the system call
number, the C arguments into the general registers and then executes
some machine instruction that generates a software interrupt in the
kernel.
10. Example on how system calls are used
• Writing a simple program to read
data from one file and copy them
to another file
• Program inputs
– Name of two files
• Program opens the input file and
create output file and open it
• Each of these operations require
another system calls
• Now that both files are setup,
enter into the loop that read
from input file (system call) and
writes into the output file
(another system call)
12. Library functions
• Library functions are the general purpose functions defined in Section 3 of
“Linux/Unix programmers Manual”
• $ man <section_no> <command_name>
• These functions are not entry points into the kernel although they may
invoke one or more of the kernel functions.
• For example, ‘printf’ may invoke the ‘write’ system call to perform the
output .
• ‘strcpy’ and ‘atoi’ doesn’t invoke the kernel service at all. They are library
functions
13. C library interface
• The standard C library provides a
portion of the system call
interface for many versions of
UNIX and Linux
• For example, the ‘printf’
statement. The C library
interprets this call and invokes
the necessary system call(s) in
the operating system in this
instance , the write() system call
• The C library takes the value
returned by write() and passes it
back to the user program.
14. User Space
system call and library function
• Examples of systems
calls
• Read() / write ()
• Fork()/ exec ()
• Example of library
functions
• Date/time
• Strcpy/atoi/printf
Application code
C library functions
System calls
15. Header Files
• The Application
programming interface (API)
of the C standard library is
declared in a number of
header files. Each header
files contains one or more
function declarations, data
types definitions and
macros.
• Header files are located
at /usr/include
Name Description
<errno.h>
Testing error code reported by library
functions.
<stdarg.h>
For accessing varying number of
arguments passed to functions
<stdatomic.h>
For atomic operations on data shared
between threads
<stddef.h> Defines several types and macros
<stdio.h> Defines core input/output APIS
<stdlib.h>
Defines memory allocation/process
control
<string.h> Defines string manipulations APIs.
<threads.h> Thread handling APIs
<time.h> Date/Time handling APIs
16. System call categories
• System calls can be roughly
grouped into five major
categories:
– Process management
– File management
– Device management
– Information/Maintenance
– Communication
• Process management
– create process the process
– Terminate process
– Load the process
– Execute the process
– get/set process attributes
– wait for time, wait event,
signal event
17. System call categories..contd…
• File management.
– create file, delete file
– open, close
– read, write, reposition
– get/set file attributes
• Device Management.
– request device, release
device
– read, write, reposition
– get/set device attributes
– logically attach or detach
devices
• Information Maintenance.
– get/set time or date
– get/set system data
– get/set process, file, or device
attributes
• Communication.
– create, delete communication
connection
– send, receive messages
– transfer status information
– attach or detach remote
devices
18. File management
• We will start our study with the functions available for the file I/O
operations such as open a file, read & write a file, close a file and so on.
• Most file IO operations are performed with the open, read, write, lseek
and close system calls.
• File descriptors
– File descriptor is a non-negative integer representing the file opened
in the kernel.
– When file is opened or newly created, the kernel returns a file
descriptor to the process.
– During read/write, the file is identified by the file descriptor that was
returned by open()
19. Open function
Open and possibly create a file or device
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);
int creat(const char *pathname, mode_t mode);
DESCRIPTION
Given a pathname for a file, open() returns a file descriptor, a small, nonnegative
integer for use in subsequent system calls (read, write, lseek, fcntl, etc.).
Flags : One of the access modes: O_RDONLY, O_WRONLY, or O_RDWR. These
request opening the file read-only, write-only, or read/write, respectively.
RETURN VALUE
open() and creat() return the new file descriptor, or -1 if an error occurred (in
which case, errno is set appropriately).
21. Close function
Close a file descriptor
SYNOPSIS
#include <unistd.h>
int close(int fd);
DESCRIPTION
close() closes a file descriptor, so that it no longer refers to any file and
may be reused.
RETURN VALUE
close() returns zero on success. On error, -1 is returned, and errno is set
appropriately.
22. Read function
Read from a file descriptor
SYNOPSIS
#include <unistd.h>
ssize_t read(int fd, void *buf, size_t count);
DESCRIPTION
read() attempts to read up to count bytes from file descriptor fd into the
buffer starting at buf.
If count is zero, read() returns zero and has no other results. If count is
greater than SSIZE_MAX, the result is
unspecified.
RETURN VALUE
On success, the number of bytes read is returned (zero indicates end of
file), and the file position is advanced by this number. On error, -1 is
returned, and errno is set appropriately.
23. Write function
Write to a file descriptor
SYNOPSIS
#include <unistd.h>
ssize_t write(int fd, const void *buf, size_t count);
DESCRIPTION
write() writes up to count bytes from the buffer pointed buf to the file
referred to by the file descriptor fd.
RETURN VALUE
On success, the number of bytes written is returned (zero indicates
nothing was written). On error, -1 is returned, and errno is set
appropriately.
25. lseek function
lseek - reposition read/write file offset
SYNOPSIS
#include <sys/types.h>
#include <unistd.h>
off_t lseek(int fd, off_t offset, int whence);
DESCRIPTION
The lseek() function repositions the offset of the open file associated with the file
descriptor fd to the argument offset according to the directive whence as follows:
SEEK_SET - The offset is set to offset bytes.
SEEK_CUR - The offset is set to its current location plus offset bytes.
SEEK_END – The offset is set to the size of the file plus offset bytes
RETURN VALUE
Upon successful completion, lseek() returns the resulting offset location as
measured in bytes from the beginning of the file. Otherwise, a value of (off_t) -1
is returned and errno is set to indicate the error.
26. access
• Testing file permissions
SYNOPSIS
– Access (const char *pathname, permission_flags)
– Permission flags - R_OK, W_OK, X_OK for read, write and execute permissions.
DESCRIPTION
The access system call determines whether the calling process has access
permission to a file.
– It can check any combination of read (r), write (w) and execute (x) permission.
– It can also check whether file exists or not.
RETURN VALUE
On success return value is 0, if process has all specified permissions,
If the file exists and process does not have the specified permissions, access
returns -1 and errno is set to EACCESS.
27. System call File Operation
open open a file or device fs/open.c
creat create a file or device
close close a file descriptor
dup2 duplicate a file descriptor
dup duplicate an open file descriptor
mmap map files into memory
(Only the PROT_READ protection flag is supported.)
munmap unmap files from memory
pread read from a file descriptor at a given offset
pwrite write to a file descriptor at a given offset
read read from a file descriptor
readv read data from multiple buffers
write write to a file descriptor
writev write data from multiple buffers
lseek reposition read/write file offset
llseek move extended read/write file pointer
lstat get file status
truncate set a file to a specified length
ftruncate set a file to a specified length
unlink delete a name and possibly the file it refers to
28. System call Sync Operation
sync update the super block
fsync synchronize the complete in-
core state of a file with that on
disk
System call
Statistics and status
Operation
fstatfs get file system statistics
fstat get file status
statfs get file system statistics
stat get file status
System call Directory Operation
chdir change working directory
chroot change root directory
fchdir change working directory
rmdir remove a directory
rename change the name or location of
a file
getdents read directory entries
mkdir create a directory
System call Permission Operation
chmod change permissions of a file
chown change ownership of a file
fchmod change access permission
mode of file
fchown change owner and group of a
file
29. Getrlimit and setrlimit: resource limit
• The getrlimit and setrlimit system calls allow a process to read and set
limits on the system resources that it can consume.
• For each resource, there are two limits
– Hard limit
– Soft limit
• Both getrlimit and setrlimit take as arguments a code specifying the
resource limit type and a pointer to a structrlimit variable.
• The getrlimit call fills the fields of this structure, while the setrlimit call
changes the limit based on its contents.
• The rlimit structure has two fields: rlim_cur is the soft limit, and rlim_max
is the hard limit.
30. • Most useful resource limits that may be changed are listed here, with their codes:
• RLIMIT_CPU
– The maximum CPU time, in seconds, used by a program. This is the amount of
time that the program is actually executing on the CPU, which is not
necessarily the same as wall-clock time.
– If the program exceeds this time limit, it is terminated with a SIGXCPU signal.
• RLIMIT_DATA
– The maximum amount of memory that a program can allocate for its data.
Additional allocation beyond this limit will fail.
• RLIMIT_NPROC
– The maximum number of child processes that can be running for this user. If
the process calls fork and too many processes belonging to this user are
running on the system, fork fails.
• RLIMIT_NOFILE
– The maximum number of file descriptors that the process may have open at
one time.
31. CPU-Time limit demonstration
• The program illustrates setting
the limit on CPU time consumed
by a program.
• It sets a 1-second CPU time limit
and then spins in an infinite loop.
Linux kills the process soon
afterward, when it exceeds 1
second of CPU time.
• When the program is terminated
by SIGXCPU, the shell helpfully
prints out a message interpreting
the signal:
• $ ./limit_cpu
• CPU time limit exceeded
#include <sys/resource.h>
#include <sys/time.h>
#include <unistd.h>
int main () {
struct rlimit rl;
/* Obtain the current limits. */
getrlimit (RLIMIT_CPU, &rl);
/* Set a CPU limit of 1 second. */
rl.rlim_cur = 1;
setrlimit (RLIMIT_CPU, &rl);
/* Do busy work. */
while (1);
return 0;
}
32. Getrusage- Process statistics
• The getrusage system call retrieves process statistics from the kernel.
• Syntax : man getrusage
• It can be used to obtain statistics either for the current process by passing
RUSAGE_SELF as the first argument, or for all terminated child processes that were
forked by this process and its children by passing RUSAGE_CHILDREN.
• The second argument to rusage is a pointer to a struct rusage variable, which is
filled with the statistics.
• A few of the more interesting fields in struct rusage are listed here:
– ru_utime—A struct timeval field containing the amount of user time, in
seconds, that the process has used. User time is CPU time spent executing the
user program, rather than in kernel system calls.
– ru_stime—A struct timeval field containing the amount of system time, in
seconds, that the process has used. System time is the CPU time spent
executing system calls on behalf of the process.
– ru_maxrss—The largest amount of physical memory occupied by the
process’s data at one time over the course of its execution.
33. Display Process user and system time
• A few of the more interesting fields in
struct rusage are listed here:
• ru_utime—A struct timeval field
containing the amount of user time, in
seconds, that the process has used. User
time is CPU time spent executing the
user program, rather than in kernel
system calls.
• ru_stime—A struct timeval field
containing the amount of system time,
in seconds, that the process has used.
System time is the CPU time spent
executing system calls on behalf of the
process.
• ru_maxrss—The largest amount of
physical memory occupied by the
process’s data at one time over the
course of its execution.
#include <stdio.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <unistd.h>
void main () {
struct rusage usage;
getrusage (RUSAGE_SELF,
&usage);
printf (“CPU time: %ld.%06ld sec
user, %ld.%06ld sec systemn”,
usage.ru_utime.tv_sec,
usage.ru_utime.tv_usec,
usage.ru_stime.tv_sec,
usage.ru_stime.tv_usec);
return 0;
}
34. Sysinfo: Obtaining system statistics
• The sysinfo system call fills a structure with system statistics. Its only
argument is a pointer to a struct sysinfo.
• Syntax : man sysinfo
• Some of the more interesting fields of struct sysinfo that are filled include
these:
• uptime—Time elapsed since the system booted, in seconds
• totalram—Total available physical RAM
• freeram—Free physical RAM
• procs—Number of processes on the system
36. Uname system
• The uname system call fills a structure with various system information,
including the computer’s network name and domain name, and the
operating system version it’s running.
• Syntax : man uname
• A single argument, a pointer to a struct utsname object.
• The call to uname fills in these fields:
– sysname—The name of the operating system (such as Linux).
– release, version—The Linux kernel release number and version level.
– machine—Some information about the hardware platform running
Linux. For x86 Linux, this is i386 or i686, depending on the processor.
– node—The computer’s unqualified hostname.
– __domain—The computer’s domain name.
• Each of these fields is a character string.
37. Print linux verion number and
hardware information
#include <stdio.h>
#include <sys/utsname.h>
int main ()
{
struct utsname u;
uname (&u);
printf (“%s release %s (version %s) on %sn”, u.sysname, u.release,
u.version, u.machine);
return 0;
}
38. Few refences
• Linux system call quick reference :
– http://www.digilife.be/quickreferences/qrc/linux%20system%20call%20quic
• Linux system call table:
– http://docs.cs.up.ac.za/programming/asm/derick_tut/syscalls.html
• Operating system concepts(Galvin), chapter 2