0% found this document useful (0 votes)
8 views15 pages

Tutorial 1

The document provides an overview of the kernel, system calls (syscalls), and processes within an operating system. It explains the role of the kernel in managing system resources and preventing conflicts, as well as detailing various syscalls like fork, exec, and open that facilitate process management and file handling. Additionally, it discusses the concept of processes, including their unique identifiers (PIDs) and the use of the fork() system call to create child processes.

Uploaded by

Shlok Sand
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views15 pages

Tutorial 1

The document provides an overview of the kernel, system calls (syscalls), and processes within an operating system. It explains the role of the kernel in managing system resources and preventing conflicts, as well as detailing various syscalls like fork, exec, and open that facilitate process management and file handling. Additionally, it discusses the concept of processes, including their unique identifiers (PIDs) and the use of the fork() system call to create child processes.

Uploaded by

Shlok Sand
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

OSN

Tutorial-1
Kernel, Syscalls and
Processes

11:50 AM
OSN• [Link]• [Link]• [Link]• [Link]• [Link]• [Link]• [Link]• Tutorial-1..OS

Topics Covered

Kernel Syscalls

Agenda
File
Processes
Management
Kernel
The kernel is a computer program at the
core of a computer's operating system and
generally has complete control over
everything in the system. The kernel is also
responsible for preventing and mitigating
conflicts between different processes. It is
the portion of the operating system code
that is always resident in memory and
facilitates interactions between hardware
and software components.

But Why cant I


rm -rf /
without sudo
But.....
But what if I wanted to open a file,
Syscalls
Think of Syscall as keys !
exec
fork

And the action of unlocking as Interupts


Threads
Processes

Memory

External Devices Syscalls Network Sockets

File System

Files

Directory

open read
Name Basic Synatx Description

List of fork pid_t fork(void);


Creates a new process by duplicating the
calling process.

Syscalls open
int open(const char *pathname, int flags,
mode_t mode);
Opens a file.

exec() has family of system calls.(one of


them) Replaces the current process image with
exec
int execve(const char *filename, char a new process image.
*const argv[], char *const envp[]);

ssize_t write(int fd, const void *buf, size_t


write Writes data to a file descriptor
count);

off_t lseek(int fd, off_t offset, int Repositions the offset of the file
lseek
whence); descriptor.
Name Basic Synatx Description

List of dup int dup(int oldfd); Duplicates a file descriptor.

Syscalls dup2 int dup2(int oldfd, int newfd);


Duplicates a file descriptor to a specified
descriptor number

pid_t waitpid(pid_t pid, int *status, int


waitpid Waits for a child process to change state.
options);

munmap int munmap(void *addr, size_t length); Unmaps files or devices from memory.

void *mmap(void *addr, size_t length, int


mmap Maps files or devices into memory.
prot, int flags, int fd, off_t offset);
WHAT IS A PROCESS?
A process can be defined as an instance of a running program
.…
What is a program?
It is a set of instructions that are used to complete a specific task.

Back to Agenda Page


PROCESS ID & GETPID()
Process ID (PID) is a unique id that is assigned to every process in the system.

It can be any number lesser than 32768 (2¹⁵) and can be increased to 4194304
(2²²) on 64-bit systems.

getpid() function can be called which returns the process ID of the calling process.

Process management refers to the activities involved in managing the execution of


multiple processes in an operating system

Back to Agenda Page


FORK( ) AND SPAWNING PROCESSES
fork() system call can be made to spawn a new
This new process is called the child of
process.
the process which made the system call

The original process making the system call is called the


parent process.

The child process is an exact clone of the parent process


and both of them execute the next instruction after fork()
Le
ga
c y
MAN PAGES
man [option] [section number] [command name]
man -f [command name]
Name: The name of the command.
Synopsis: The command’s syntax.
Configuration: Configuration details for a device.
Description: A description of the command.
Examples: Several examples demonstrating the use of the command. man [section number] [command name]
Defaults: The default functions of the command and how they can be overridden.
Options: A list of options and flags that the command accepts.
Exit Status: A list of possible exit status values for the command.
Environment: A list and description of environment variables that affect the command.
Files: A list of files used by the command.
See also: Commands related to the described topic.
Authors: The people who wrote or maintain the command.
History: Command development history.
Notes: Various notes, including permissions required, dependencies, etc.
Bugs: Any known issues in this program version.

Back to Agenda Page


Is this useful for mp -0 ?????

You might also like