SlideShare ist ein Scribd-Unternehmen logo
1 von 67
Downloaden Sie, um offline zu lesen
Lab 5: System calls
Advanced Operating Systems

Zubair Nabi
zubair.nabi@itu.edu.pk

February 27, 2013
Normal execution of a processor

While running a user process:
1

Read an instruction

2

Advance the program counter

3

Execute the instruction

4

Jump to 1
Normal execution of a processor

While running a user process:
1

Read an instruction

2

Advance the program counter

3

Execute the instruction

4

Jump to 1
Normal execution of a processor

While running a user process:
1

Read an instruction

2

Advance the program counter

3

Execute the instruction

4

Jump to 1
Normal execution of a processor

While running a user process:
1

Read an instruction

2

Advance the program counter

3

Execute the instruction

4

Jump to 1
Normal execution of a processor

While running a user process:
1

Read an instruction

2

Advance the program counter

3

Execute the instruction

4

Jump to 1
Extraordinary events

Events that break normal processor flow, to return control to the
kernel:
1

A device signals that it needs attention (e.g. Timer): Interrupt

2

A user program does something illegal (e.g. divide by zero):
Exception

3

A user program asks the kernel for a service: System call
Extraordinary events

Events that break normal processor flow, to return control to the
kernel:
1

A device signals that it needs attention (e.g. Timer): Interrupt

2

A user program does something illegal (e.g. divide by zero):
Exception

3

A user program asks the kernel for a service: System call
Extraordinary events

Events that break normal processor flow, to return control to the
kernel:
1

A device signals that it needs attention (e.g. Timer): Interrupt

2

A user program does something illegal (e.g. divide by zero):
Exception

3

A user program asks the kernel for a service: System call
Extraordinary events

Events that break normal processor flow, to return control to the
kernel:
1

A device signals that it needs attention (e.g. Timer): Interrupt

2

A user program does something illegal (e.g. divide by zero):
Exception

3

A user program asks the kernel for a service: System call
Handling extraordinary events

The operating system must:
1

Save the processor’s registers for future resumption

2

Set up system for execution in the kernel

3

Choose a place for the kernel to start execution

4

Retrieve information about the event and call corresponding

interrupt handler
5

All the while, maintain isolation between user processes and the
kernel
Handling extraordinary events

The operating system must:
1

Save the processor’s registers for future resumption

2

Set up system for execution in the kernel

3

Choose a place for the kernel to start execution

4

Retrieve information about the event and call corresponding

interrupt handler
5

All the while, maintain isolation between user processes and the
kernel
Handling extraordinary events

The operating system must:
1

Save the processor’s registers for future resumption

2

Set up system for execution in the kernel

3

Choose a place for the kernel to start execution

4

Retrieve information about the event and call corresponding

interrupt handler
5

All the while, maintain isolation between user processes and the
kernel
Handling extraordinary events

The operating system must:
1

Save the processor’s registers for future resumption

2

Set up system for execution in the kernel

3

Choose a place for the kernel to start execution

4

Retrieve information about the event and call corresponding

interrupt handler
5

All the while, maintain isolation between user processes and the
kernel
Handling extraordinary events

The operating system must:
1

Save the processor’s registers for future resumption

2

Set up system for execution in the kernel

3

Choose a place for the kernel to start execution

4

Retrieve information about the event and call corresponding

interrupt handler
5

All the while, maintain isolation between user processes and the
kernel
Handling extraordinary events

The operating system must:
1

Save the processor’s registers for future resumption

2

Set up system for execution in the kernel

3

Choose a place for the kernel to start execution

4

Retrieve information about the event and call corresponding

interrupt handler
5

All the while, maintain isolation between user processes and the
kernel
Handling extraordinary events (2)

• Need hardware support
• On the x86, system calls generate an interrupt via the int
instruction
• The same mechanism for handling interrupts is used for handling
system calls and exceptions
• Traps are caused by the current running process
• Interrupts are caused by devices
• Can happen concurrently
Handling extraordinary events (2)

• Need hardware support
• On the x86, system calls generate an interrupt via the int
instruction
• The same mechanism for handling interrupts is used for handling
system calls and exceptions
• Traps are caused by the current running process
• Interrupts are caused by devices
• Can happen concurrently
Handling extraordinary events (2)

• Need hardware support
• On the x86, system calls generate an interrupt via the int
instruction
• The same mechanism for handling interrupts is used for handling
system calls and exceptions
• Traps are caused by the current running process
• Interrupts are caused by devices
• Can happen concurrently
Handling extraordinary events (2)

• Need hardware support
• On the x86, system calls generate an interrupt via the int
instruction
• The same mechanism for handling interrupts is used for handling
system calls and exceptions
• Traps are caused by the current running process
• Interrupts are caused by devices
• Can happen concurrently
Handling extraordinary events (2)

• Need hardware support
• On the x86, system calls generate an interrupt via the int
instruction
• The same mechanism for handling interrupts is used for handling
system calls and exceptions
• Traps are caused by the current running process
• Interrupts are caused by devices
• Can happen concurrently
Handling extraordinary events (2)

• Need hardware support
• On the x86, system calls generate an interrupt via the int
instruction
• The same mechanism for handling interrupts is used for handling
system calls and exceptions
• Traps are caused by the current running process
• Interrupts are caused by devices
• Can happen concurrently
x86 protection

• 4 protection levels: 0 to 3
• Privilege decreases in ascending order

• Most operating systems only use 2 levels: 0 (kernel mode) and 3
(user mode)
• Interrupt handlers are defined in an interrupt descriptor table
(idt) with a total of 256 entries
• int n generates a system call, where n is used to index the

idt
• It is the job of the operating system to implement a handler for
each entry in the idt
x86 protection

• 4 protection levels: 0 to 3
• Privilege decreases in ascending order

• Most operating systems only use 2 levels: 0 (kernel mode) and 3
(user mode)
• Interrupt handlers are defined in an interrupt descriptor table
(idt) with a total of 256 entries
• int n generates a system call, where n is used to index the

idt
• It is the job of the operating system to implement a handler for
each entry in the idt
x86 protection

• 4 protection levels: 0 to 3
• Privilege decreases in ascending order

• Most operating systems only use 2 levels: 0 (kernel mode) and 3
(user mode)
• Interrupt handlers are defined in an interrupt descriptor table
(idt) with a total of 256 entries
• int n generates a system call, where n is used to index the

idt
• It is the job of the operating system to implement a handler for
each entry in the idt
x86 protection

• 4 protection levels: 0 to 3
• Privilege decreases in ascending order

• Most operating systems only use 2 levels: 0 (kernel mode) and 3
(user mode)
• Interrupt handlers are defined in an interrupt descriptor table
(idt) with a total of 256 entries
• int n generates a system call, where n is used to index the

idt
• It is the job of the operating system to implement a handler for
each entry in the idt
x86 protection

• 4 protection levels: 0 to 3
• Privilege decreases in ascending order

• Most operating systems only use 2 levels: 0 (kernel mode) and 3
(user mode)
• Interrupt handlers are defined in an interrupt descriptor table
(idt) with a total of 256 entries
• int n generates a system call, where n is used to index the

idt
• It is the job of the operating system to implement a handler for
each entry in the idt
x86 protection

• 4 protection levels: 0 to 3
• Privilege decreases in ascending order

• Most operating systems only use 2 levels: 0 (kernel mode) and 3
(user mode)
• Interrupt handlers are defined in an interrupt descriptor table
(idt) with a total of 256 entries
• int n generates a system call, where n is used to index the

idt
• It is the job of the operating system to implement a handler for
each entry in the idt
x86 protection

• 4 protection levels: 0 to 3
• Privilege decreases in ascending order

• Most operating systems only use 2 levels: 0 (kernel mode) and 3
(user mode)
• Interrupt handlers are defined in an interrupt descriptor table
(idt) with a total of 256 entries
• int n generates a system call, where n is used to index the

idt
• It is the job of the operating system to implement a handler for
each entry in the idt
int

• Fetches the nth descriptor from idt
• Ensures that the privilege level in the descriptor is 3
• As the interrupt is due to a user process, saves the process state
(change in privilege level)
• Sets the instructor pointer to the required starting address in the
descriptor table and starts execution
• After execution, the OS calls iret to resume previous execution
state
int

• Fetches the nth descriptor from idt
• Ensures that the privilege level in the descriptor is 3
• As the interrupt is due to a user process, saves the process state
(change in privilege level)
• Sets the instructor pointer to the required starting address in the
descriptor table and starts execution
• After execution, the OS calls iret to resume previous execution
state
int

• Fetches the nth descriptor from idt
• Ensures that the privilege level in the descriptor is 3
• As the interrupt is due to a user process, saves the process state
(change in privilege level)
• Sets the instructor pointer to the required starting address in the
descriptor table and starts execution
• After execution, the OS calls iret to resume previous execution
state
int

• Fetches the nth descriptor from idt
• Ensures that the privilege level in the descriptor is 3
• As the interrupt is due to a user process, saves the process state
(change in privilege level)
• Sets the instructor pointer to the required starting address in the
descriptor table and starts execution
• After execution, the OS calls iret to resume previous execution
state
int

• Fetches the nth descriptor from idt
• Ensures that the privilege level in the descriptor is 3
• As the interrupt is due to a user process, saves the process state
(change in privilege level)
• Sets the instructor pointer to the required starting address in the
descriptor table and starts execution
• After execution, the OS calls iret to resume previous execution
state
The first system call

• Recall that initcode.S started off by invoking an exec
system call to load the init process (/init)
• Flow:
1 Push the arguments and binary for exec on the process’s stack
2 Put the system call number (SYS_exec) in %eax (obviously this
number should already be present in the system call table,
*syscalls[])
3 Execute int T_SYSCALL
The first system call

• Recall that initcode.S started off by invoking an exec
system call to load the init process (/init)
• Flow:
1 Push the arguments and binary for exec on the process’s stack
2 Put the system call number (SYS_exec) in %eax (obviously this
number should already be present in the system call table,
*syscalls[])
3 Execute int T_SYSCALL
The first system call

• Recall that initcode.S started off by invoking an exec
system call to load the init process (/init)
• Flow:
1 Push the arguments and binary for exec on the process’s stack
2 Put the system call number (SYS_exec) in %eax (obviously this
number should already be present in the system call table,
*syscalls[])
3 Execute int T_SYSCALL
The first system call

• Recall that initcode.S started off by invoking an exec
system call to load the init process (/init)
• Flow:
1 Push the arguments and binary for exec on the process’s stack
2 Put the system call number (SYS_exec) in %eax (obviously this
number should already be present in the system call table,
*syscalls[])
3 Execute int T_SYSCALL
The first system call

• Recall that initcode.S started off by invoking an exec
system call to load the init process (/init)
• Flow:
1 Push the arguments and binary for exec on the process’s stack
2 Put the system call number (SYS_exec) in %eax (obviously this
number should already be present in the system call table,
*syscalls[])
3 Execute int T_SYSCALL
x86 traps

• 256 different interrupts
• 0-31 software
• 32-63 hardware
• 64 system calls (T_SYSCALL)
x86 traps

• 256 different interrupts
• 0-31 software
• 32-63 hardware
• 64 system calls (T_SYSCALL)
x86 traps

• 256 different interrupts
• 0-31 software
• 32-63 hardware
• 64 system calls (T_SYSCALL)
x86 traps

• 256 different interrupts
• 0-31 software
• 32-63 hardware
• 64 system calls (T_SYSCALL)
Setting up idt

• tvinit, called from main, sets up the entries in idt
• The address of the handler for each interrupt in idt is present in
vectors[], i.e. Interrupt i is handled by vectors[i]
• T_SYSCALL is handled specially: it is distinguished as a trap
allowing multiple system calls to execute simultaneously
Setting up idt

• tvinit, called from main, sets up the entries in idt
• The address of the handler for each interrupt in idt is present in
vectors[], i.e. Interrupt i is handled by vectors[i]
• T_SYSCALL is handled specially: it is distinguished as a trap
allowing multiple system calls to execute simultaneously
Setting up idt

• tvinit, called from main, sets up the entries in idt
• The address of the handler for each interrupt in idt is present in
vectors[], i.e. Interrupt i is handled by vectors[i]
• T_SYSCALL is handled specially: it is distinguished as a trap
allowing multiple system calls to execute simultaneously
tvinit
1
2
3
4
5
6
7
8
9
10
11
12
13
14

void tvinit (void) {
int i;
for(i = 0; i < 256; i++)
SETGATE (idt[i], 0, SEG_KCODE <<3, vectors [i], 0);
SETGATE (idt[ T_SYSCALL ], 1, SEG_KCODE <<3,
vectors [ T_SYSCALL ], DPL_USER );
/∗ SETGATE (gate , istrap , sel , off , d)

∗
∗
∗
∗
∗

gate: idt entry
istrap : 1 trap , 0 interrupt
sel: code segment
off: offset within code segment
d: privilege level

∗/

initlock (& tickslock , "time");
}
Addresses of interrupt handlers

• xv6 uses a custom Perl script vectors.pl to generate
vectors.S which holds entry points of interrupt handlers in

vectors[]
• Each entry point:
Pushes an error code
Pushes the interrupt number
3 Jumps to alltraps
1
2
Addresses of interrupt handlers

• xv6 uses a custom Perl script vectors.pl to generate
vectors.S which holds entry points of interrupt handlers in

vectors[]
• Each entry point:
Pushes an error code
Pushes the interrupt number
3 Jumps to alltraps

1

2
Addresses of interrupt handlers

• xv6 uses a custom Perl script vectors.pl to generate
vectors.S which holds entry points of interrupt handlers in

vectors[]
• Each entry point:
Pushes an error code
Pushes the interrupt number
3 Jumps to alltraps

1

2
Addresses of interrupt handlers

• xv6 uses a custom Perl script vectors.pl to generate
vectors.S which holds entry points of interrupt handlers in

vectors[]
• Each entry point:
Pushes an error code
Pushes the interrupt number
3 Jumps to alltraps

1

2
alltraps

1

Pushes all processor registers into a struct trapframe
• Once the call completes, the kernel can restore state from this
structure

2

Sets up the processor to run kernel C code (load SEG_KCPU,
per-CPU data segment)

3

Calls the C trap handler trap

4

Once trap returns, alltraps restores struct
trapframe and then calls iret to return control back to user
space
alltraps

1

Pushes all processor registers into a struct trapframe
• Once the call completes, the kernel can restore state from this
structure

2

Sets up the processor to run kernel C code (load SEG_KCPU,
per-CPU data segment)

3

Calls the C trap handler trap

4

Once trap returns, alltraps restores struct
trapframe and then calls iret to return control back to user
space
alltraps

1

Pushes all processor registers into a struct trapframe
• Once the call completes, the kernel can restore state from this
structure

2

Sets up the processor to run kernel C code (load SEG_KCPU,
per-CPU data segment)

3

Calls the C trap handler trap

4

Once trap returns, alltraps restores struct
trapframe and then calls iret to return control back to user
space
alltraps

1

Pushes all processor registers into a struct trapframe
• Once the call completes, the kernel can restore state from this
structure

2

Sets up the processor to run kernel C code (load SEG_KCPU,
per-CPU data segment)

3

Calls the C trap handler trap

4

Once trap returns, alltraps restores struct
trapframe and then calls iret to return control back to user
space
alltraps

1

Pushes all processor registers into a struct trapframe
• Once the call completes, the kernel can restore state from this
structure

2

Sets up the processor to run kernel C code (load SEG_KCPU,
per-CPU data segment)

3

Calls the C trap handler trap

4

Once trap returns, alltraps restores struct
trapframe and then calls iret to return control back to user
space
trap

• Gets passed struct trapframe *tf
• Checks tf->trapno to decide if it was called for a system call
(T_SYSCALL) or a hardware interrupt or an exception
• In case of:
1 System call, it invokes syscall
2
3

Hardware interrupt, it calls the hardware interrupt controller
Exception, it prints the details and kills the user process
trap

• Gets passed struct trapframe *tf
• Checks tf->trapno to decide if it was called for a system call
(T_SYSCALL) or a hardware interrupt or an exception
• In case of:
1 System call, it invokes syscall
2
3

Hardware interrupt, it calls the hardware interrupt controller
Exception, it prints the details and kills the user process
trap

• Gets passed struct trapframe *tf
• Checks tf->trapno to decide if it was called for a system call
(T_SYSCALL) or a hardware interrupt or an exception
• In case of:
1 System call, it invokes syscall
2
3

Hardware interrupt, it calls the hardware interrupt controller
Exception, it prints the details and kills the user process
trap

• Gets passed struct trapframe *tf
• Checks tf->trapno to decide if it was called for a system call
(T_SYSCALL) or a hardware interrupt or an exception
• In case of:
1 System call, it invokes syscall
2
3

Hardware interrupt, it calls the hardware interrupt controller
Exception, it prints the details and kills the user process
trap

• Gets passed struct trapframe *tf
• Checks tf->trapno to decide if it was called for a system call
(T_SYSCALL) or a hardware interrupt or an exception
• In case of:
1 System call, it invokes syscall
2
3

Hardware interrupt, it calls the hardware interrupt controller
Exception, it prints the details and kills the user process
syscall

• Loads the system call number through proc->tf->eax
• Calls the corresponding system call from the syscalls table
• Puts its return value in proc->tf->eax (available on return to
user space)
• Conventionally negative numbers indicate errors while positive
ones indicate success

• System call arguments are retrieved using either argint,
argptr, or argstr
syscall

• Loads the system call number through proc->tf->eax
• Calls the corresponding system call from the syscalls table
• Puts its return value in proc->tf->eax (available on return to
user space)
• Conventionally negative numbers indicate errors while positive
ones indicate success

• System call arguments are retrieved using either argint,
argptr, or argstr
syscall

• Loads the system call number through proc->tf->eax
• Calls the corresponding system call from the syscalls table
• Puts its return value in proc->tf->eax (available on return to
user space)
• Conventionally negative numbers indicate errors while positive
ones indicate success

• System call arguments are retrieved using either argint,
argptr, or argstr
syscall

• Loads the system call number through proc->tf->eax
• Calls the corresponding system call from the syscalls table
• Puts its return value in proc->tf->eax (available on return to
user space)
• Conventionally negative numbers indicate errors while positive
ones indicate success

• System call arguments are retrieved using either argint,
argptr, or argstr
syscall

• Loads the system call number through proc->tf->eax
• Calls the corresponding system call from the syscalls table
• Puts its return value in proc->tf->eax (available on return to
user space)
• Conventionally negative numbers indicate errors while positive
ones indicate success

• System call arguments are retrieved using either argint,
argptr, or argstr
Reading(s)

• Chapter 3, “Traps, interrupts, and drivers”, till section “Code:
System calls" from “xv6: a simple, Unix-like teaching operating
system”

Weitere ähnliche Inhalte

Was ist angesagt?

Kernel Recipes 2015: Solving the Linux storage scalability bottlenecks
Kernel Recipes 2015: Solving the Linux storage scalability bottlenecksKernel Recipes 2015: Solving the Linux storage scalability bottlenecks
Kernel Recipes 2015: Solving the Linux storage scalability bottlenecksAnne Nicolas
 
Kernel module programming
Kernel module programmingKernel module programming
Kernel module programmingVandana Salve
 
Linux System Programming - Advanced File I/O
Linux System Programming - Advanced File I/OLinux System Programming - Advanced File I/O
Linux System Programming - Advanced File I/OYourHelper1
 
Hardware Probing in the Linux Kernel
Hardware Probing in the Linux KernelHardware Probing in the Linux Kernel
Hardware Probing in the Linux KernelKernel TLV
 
Char Drivers And Debugging Techniques
Char Drivers And Debugging TechniquesChar Drivers And Debugging Techniques
Char Drivers And Debugging TechniquesYourHelper1
 
Linux for embedded_systems
Linux for embedded_systemsLinux for embedded_systems
Linux for embedded_systemsVandana Salve
 
Linux System Programming - File I/O
Linux System Programming - File I/O Linux System Programming - File I/O
Linux System Programming - File I/O YourHelper1
 
Linux System Programming - Buffered I/O
Linux System Programming - Buffered I/O Linux System Programming - Buffered I/O
Linux System Programming - Buffered I/O YourHelper1
 
The Linux Scheduler: a Decade of Wasted Cores
The Linux Scheduler: a Decade of Wasted CoresThe Linux Scheduler: a Decade of Wasted Cores
The Linux Scheduler: a Decade of Wasted Coresyeokm1
 
Processes in unix
Processes in unixProcesses in unix
Processes in unixmiau_max
 
Kernel Module Programming
Kernel Module ProgrammingKernel Module Programming
Kernel Module ProgrammingSaurabh Bangad
 

Was ist angesagt? (20)

Unix kernal
Unix kernalUnix kernal
Unix kernal
 
Kernel Recipes 2015: Solving the Linux storage scalability bottlenecks
Kernel Recipes 2015: Solving the Linux storage scalability bottlenecksKernel Recipes 2015: Solving the Linux storage scalability bottlenecks
Kernel Recipes 2015: Solving the Linux storage scalability bottlenecks
 
Kernel module programming
Kernel module programmingKernel module programming
Kernel module programming
 
Linux System Programming - Advanced File I/O
Linux System Programming - Advanced File I/OLinux System Programming - Advanced File I/O
Linux System Programming - Advanced File I/O
 
Making Linux do Hard Real-time
Making Linux do Hard Real-timeMaking Linux do Hard Real-time
Making Linux do Hard Real-time
 
Ch2
Ch2Ch2
Ch2
 
Hardware Probing in the Linux Kernel
Hardware Probing in the Linux KernelHardware Probing in the Linux Kernel
Hardware Probing in the Linux Kernel
 
Char Drivers And Debugging Techniques
Char Drivers And Debugging TechniquesChar Drivers And Debugging Techniques
Char Drivers And Debugging Techniques
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Linux for embedded_systems
Linux for embedded_systemsLinux for embedded_systems
Linux for embedded_systems
 
Linux System Programming - File I/O
Linux System Programming - File I/O Linux System Programming - File I/O
Linux System Programming - File I/O
 
Tuned
TunedTuned
Tuned
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
Linux System Programming - Buffered I/O
Linux System Programming - Buffered I/O Linux System Programming - Buffered I/O
Linux System Programming - Buffered I/O
 
Basic Linux kernel
Basic Linux kernelBasic Linux kernel
Basic Linux kernel
 
The Linux Scheduler: a Decade of Wasted Cores
The Linux Scheduler: a Decade of Wasted CoresThe Linux Scheduler: a Decade of Wasted Cores
The Linux Scheduler: a Decade of Wasted Cores
 
Processes in unix
Processes in unixProcesses in unix
Processes in unix
 
Kernel Module Programming
Kernel Module ProgrammingKernel Module Programming
Kernel Module Programming
 
Linux Kernel I/O Schedulers
Linux Kernel I/O SchedulersLinux Kernel I/O Schedulers
Linux Kernel I/O Schedulers
 
Daemons
DaemonsDaemons
Daemons
 

Andere mochten auch

AOS Lab 7: Page tables
AOS Lab 7: Page tablesAOS Lab 7: Page tables
AOS Lab 7: Page tablesZubair Nabi
 
AOS Lab 2: Hello, xv6!
AOS Lab 2: Hello, xv6!AOS Lab 2: Hello, xv6!
AOS Lab 2: Hello, xv6!Zubair Nabi
 
AOS Lab 10: File system -- Inodes and beyond
AOS Lab 10: File system -- Inodes and beyondAOS Lab 10: File system -- Inodes and beyond
AOS Lab 10: File system -- Inodes and beyondZubair Nabi
 
Topic 13: Cloud Stacks
Topic 13: Cloud StacksTopic 13: Cloud Stacks
Topic 13: Cloud StacksZubair Nabi
 
AOS Lab 9: File system -- Of buffers, logs, and blocks
AOS Lab 9: File system -- Of buffers, logs, and blocksAOS Lab 9: File system -- Of buffers, logs, and blocks
AOS Lab 9: File system -- Of buffers, logs, and blocksZubair Nabi
 
Topic 14: Operating Systems and Virtualization
Topic 14: Operating Systems and VirtualizationTopic 14: Operating Systems and Virtualization
Topic 14: Operating Systems and VirtualizationZubair Nabi
 
Topic 15: Datacenter Design and Networking
Topic 15: Datacenter Design and NetworkingTopic 15: Datacenter Design and Networking
Topic 15: Datacenter Design and NetworkingZubair Nabi
 
MapReduce and DBMS Hybrids
MapReduce and DBMS HybridsMapReduce and DBMS Hybrids
MapReduce and DBMS HybridsZubair Nabi
 
MapReduce Application Scripting
MapReduce Application ScriptingMapReduce Application Scripting
MapReduce Application ScriptingZubair Nabi
 
Raabta: Low-cost Video Conferencing for the Developing World
Raabta: Low-cost Video Conferencing for the Developing WorldRaabta: Low-cost Video Conferencing for the Developing World
Raabta: Low-cost Video Conferencing for the Developing WorldZubair Nabi
 
AOS Lab 1: Hello, Linux!
AOS Lab 1: Hello, Linux!AOS Lab 1: Hello, Linux!
AOS Lab 1: Hello, Linux!Zubair Nabi
 
The Anatomy of Web Censorship in Pakistan
The Anatomy of Web Censorship in PakistanThe Anatomy of Web Censorship in Pakistan
The Anatomy of Web Censorship in PakistanZubair Nabi
 
The Big Data Stack
The Big Data StackThe Big Data Stack
The Big Data StackZubair Nabi
 
Inter process communication using Linux System Calls
Inter process communication using Linux System CallsInter process communication using Linux System Calls
Inter process communication using Linux System Callsjyoti9vssut
 

Andere mochten auch (14)

AOS Lab 7: Page tables
AOS Lab 7: Page tablesAOS Lab 7: Page tables
AOS Lab 7: Page tables
 
AOS Lab 2: Hello, xv6!
AOS Lab 2: Hello, xv6!AOS Lab 2: Hello, xv6!
AOS Lab 2: Hello, xv6!
 
AOS Lab 10: File system -- Inodes and beyond
AOS Lab 10: File system -- Inodes and beyondAOS Lab 10: File system -- Inodes and beyond
AOS Lab 10: File system -- Inodes and beyond
 
Topic 13: Cloud Stacks
Topic 13: Cloud StacksTopic 13: Cloud Stacks
Topic 13: Cloud Stacks
 
AOS Lab 9: File system -- Of buffers, logs, and blocks
AOS Lab 9: File system -- Of buffers, logs, and blocksAOS Lab 9: File system -- Of buffers, logs, and blocks
AOS Lab 9: File system -- Of buffers, logs, and blocks
 
Topic 14: Operating Systems and Virtualization
Topic 14: Operating Systems and VirtualizationTopic 14: Operating Systems and Virtualization
Topic 14: Operating Systems and Virtualization
 
Topic 15: Datacenter Design and Networking
Topic 15: Datacenter Design and NetworkingTopic 15: Datacenter Design and Networking
Topic 15: Datacenter Design and Networking
 
MapReduce and DBMS Hybrids
MapReduce and DBMS HybridsMapReduce and DBMS Hybrids
MapReduce and DBMS Hybrids
 
MapReduce Application Scripting
MapReduce Application ScriptingMapReduce Application Scripting
MapReduce Application Scripting
 
Raabta: Low-cost Video Conferencing for the Developing World
Raabta: Low-cost Video Conferencing for the Developing WorldRaabta: Low-cost Video Conferencing for the Developing World
Raabta: Low-cost Video Conferencing for the Developing World
 
AOS Lab 1: Hello, Linux!
AOS Lab 1: Hello, Linux!AOS Lab 1: Hello, Linux!
AOS Lab 1: Hello, Linux!
 
The Anatomy of Web Censorship in Pakistan
The Anatomy of Web Censorship in PakistanThe Anatomy of Web Censorship in Pakistan
The Anatomy of Web Censorship in Pakistan
 
The Big Data Stack
The Big Data StackThe Big Data Stack
The Big Data Stack
 
Inter process communication using Linux System Calls
Inter process communication using Linux System CallsInter process communication using Linux System Calls
Inter process communication using Linux System Calls
 

Ähnlich wie AOS Lab 5: System calls

Multithreaded Programming Part- III.pdf
Multithreaded Programming Part- III.pdfMultithreaded Programming Part- III.pdf
Multithreaded Programming Part- III.pdfHarika Pudugosula
 
Advanced Operating Systems......Process Management
Advanced Operating Systems......Process ManagementAdvanced Operating Systems......Process Management
Advanced Operating Systems......Process ManagementVeejeya Kumbhar
 
03_Top Level View of Computer Function and Interconnection.ppt
03_Top Level View of Computer Function and Interconnection.ppt03_Top Level View of Computer Function and Interconnection.ppt
03_Top Level View of Computer Function and Interconnection.pptChABiDRazZaQ
 
IT241 - Full Summary.pdf
IT241 - Full Summary.pdfIT241 - Full Summary.pdf
IT241 - Full Summary.pdfSHEHABALYAMANI
 
Operating system enhancements to prevent misuse of systems
Operating system enhancements to prevent misuse of systemsOperating system enhancements to prevent misuse of systems
Operating system enhancements to prevent misuse of systemsDayal Dilli
 
Operating system 22 threading issues
Operating system 22 threading issuesOperating system 22 threading issues
Operating system 22 threading issuesVaibhav Khanna
 
Part 04 Creating a System Call in Linux
Part 04 Creating a System Call in LinuxPart 04 Creating a System Call in Linux
Part 04 Creating a System Call in LinuxTushar B Kute
 
How Operating system works.
How Operating system works. How Operating system works.
How Operating system works. Fahad Farooq
 
Introduction to Operating Systems - Mary Margarat
Introduction to Operating Systems - Mary MargaratIntroduction to Operating Systems - Mary Margarat
Introduction to Operating Systems - Mary MargaratMary Margarat
 
Operating Systems PPT 1 (1).pdf
Operating Systems PPT 1 (1).pdfOperating Systems PPT 1 (1).pdf
Operating Systems PPT 1 (1).pdfFahanaAbdulVahab
 
Interrupt in real time system
Interrupt in real time system Interrupt in real time system
Interrupt in real time system ali jawad
 
Engg-0505-IT-Operating-Systems-2nd-year.pdf
Engg-0505-IT-Operating-Systems-2nd-year.pdfEngg-0505-IT-Operating-Systems-2nd-year.pdf
Engg-0505-IT-Operating-Systems-2nd-year.pdfnikhil287188
 

Ähnlich wie AOS Lab 5: System calls (20)

Os introduction
Os introductionOs introduction
Os introduction
 
Os introduction
Os introductionOs introduction
Os introduction
 
Interrupts.ppt
Interrupts.pptInterrupts.ppt
Interrupts.ppt
 
Windows kernel
Windows kernelWindows kernel
Windows kernel
 
Multithreaded Programming Part- III.pdf
Multithreaded Programming Part- III.pdfMultithreaded Programming Part- III.pdf
Multithreaded Programming Part- III.pdf
 
Advanced Operating Systems......Process Management
Advanced Operating Systems......Process ManagementAdvanced Operating Systems......Process Management
Advanced Operating Systems......Process Management
 
Os lectures
Os lecturesOs lectures
Os lectures
 
03_Top Level View of Computer Function and Interconnection.ppt
03_Top Level View of Computer Function and Interconnection.ppt03_Top Level View of Computer Function and Interconnection.ppt
03_Top Level View of Computer Function and Interconnection.ppt
 
IT241 - Full Summary.pdf
IT241 - Full Summary.pdfIT241 - Full Summary.pdf
IT241 - Full Summary.pdf
 
Operating system enhancements to prevent misuse of systems
Operating system enhancements to prevent misuse of systemsOperating system enhancements to prevent misuse of systems
Operating system enhancements to prevent misuse of systems
 
Operating system 22 threading issues
Operating system 22 threading issuesOperating system 22 threading issues
Operating system 22 threading issues
 
Part 04 Creating a System Call in Linux
Part 04 Creating a System Call in LinuxPart 04 Creating a System Call in Linux
Part 04 Creating a System Call in Linux
 
How Operating system works.
How Operating system works. How Operating system works.
How Operating system works.
 
Introduction to Operating Systems - Mary Margarat
Introduction to Operating Systems - Mary MargaratIntroduction to Operating Systems - Mary Margarat
Introduction to Operating Systems - Mary Margarat
 
Operating Systems PPT 1 (1).pdf
Operating Systems PPT 1 (1).pdfOperating Systems PPT 1 (1).pdf
Operating Systems PPT 1 (1).pdf
 
Lec 2
Lec 2Lec 2
Lec 2
 
Interrupt in real time system
Interrupt in real time system Interrupt in real time system
Interrupt in real time system
 
Operating Systems
Operating Systems Operating Systems
Operating Systems
 
Engg-0505-IT-Operating-Systems-2nd-year.pdf
Engg-0505-IT-Operating-Systems-2nd-year.pdfEngg-0505-IT-Operating-Systems-2nd-year.pdf
Engg-0505-IT-Operating-Systems-2nd-year.pdf
 
OS Content.pdf
OS Content.pdfOS Content.pdf
OS Content.pdf
 

Mehr von Zubair Nabi

Lab 5: Interconnecting a Datacenter using Mininet
Lab 5: Interconnecting a Datacenter using MininetLab 5: Interconnecting a Datacenter using Mininet
Lab 5: Interconnecting a Datacenter using MininetZubair Nabi
 
Topic 12: NoSQL in Action
Topic 12: NoSQL in ActionTopic 12: NoSQL in Action
Topic 12: NoSQL in ActionZubair Nabi
 
Lab 4: Interfacing with Cassandra
Lab 4: Interfacing with CassandraLab 4: Interfacing with Cassandra
Lab 4: Interfacing with CassandraZubair Nabi
 
Topic 10: Taxonomy of Data and Storage
Topic 10: Taxonomy of Data and StorageTopic 10: Taxonomy of Data and Storage
Topic 10: Taxonomy of Data and StorageZubair Nabi
 
Topic 11: Google Filesystem
Topic 11: Google FilesystemTopic 11: Google Filesystem
Topic 11: Google FilesystemZubair Nabi
 
Lab 3: Writing a Naiad Application
Lab 3: Writing a Naiad ApplicationLab 3: Writing a Naiad Application
Lab 3: Writing a Naiad ApplicationZubair Nabi
 
Topic 8: Enhancements and Alternative Architectures
Topic 8: Enhancements and Alternative ArchitecturesTopic 8: Enhancements and Alternative Architectures
Topic 8: Enhancements and Alternative ArchitecturesZubair Nabi
 
Topic 7: Shortcomings in the MapReduce Paradigm
Topic 7: Shortcomings in the MapReduce ParadigmTopic 7: Shortcomings in the MapReduce Paradigm
Topic 7: Shortcomings in the MapReduce ParadigmZubair Nabi
 
Lab 1: Introduction to Amazon EC2 and MPI
Lab 1: Introduction to Amazon EC2 and MPILab 1: Introduction to Amazon EC2 and MPI
Lab 1: Introduction to Amazon EC2 and MPIZubair Nabi
 
Topic 6: MapReduce Applications
Topic 6: MapReduce ApplicationsTopic 6: MapReduce Applications
Topic 6: MapReduce ApplicationsZubair Nabi
 

Mehr von Zubair Nabi (11)

Lab 5: Interconnecting a Datacenter using Mininet
Lab 5: Interconnecting a Datacenter using MininetLab 5: Interconnecting a Datacenter using Mininet
Lab 5: Interconnecting a Datacenter using Mininet
 
Topic 12: NoSQL in Action
Topic 12: NoSQL in ActionTopic 12: NoSQL in Action
Topic 12: NoSQL in Action
 
Lab 4: Interfacing with Cassandra
Lab 4: Interfacing with CassandraLab 4: Interfacing with Cassandra
Lab 4: Interfacing with Cassandra
 
Topic 10: Taxonomy of Data and Storage
Topic 10: Taxonomy of Data and StorageTopic 10: Taxonomy of Data and Storage
Topic 10: Taxonomy of Data and Storage
 
Topic 11: Google Filesystem
Topic 11: Google FilesystemTopic 11: Google Filesystem
Topic 11: Google Filesystem
 
Lab 3: Writing a Naiad Application
Lab 3: Writing a Naiad ApplicationLab 3: Writing a Naiad Application
Lab 3: Writing a Naiad Application
 
Topic 9: MR+
Topic 9: MR+Topic 9: MR+
Topic 9: MR+
 
Topic 8: Enhancements and Alternative Architectures
Topic 8: Enhancements and Alternative ArchitecturesTopic 8: Enhancements and Alternative Architectures
Topic 8: Enhancements and Alternative Architectures
 
Topic 7: Shortcomings in the MapReduce Paradigm
Topic 7: Shortcomings in the MapReduce ParadigmTopic 7: Shortcomings in the MapReduce Paradigm
Topic 7: Shortcomings in the MapReduce Paradigm
 
Lab 1: Introduction to Amazon EC2 and MPI
Lab 1: Introduction to Amazon EC2 and MPILab 1: Introduction to Amazon EC2 and MPI
Lab 1: Introduction to Amazon EC2 and MPI
 
Topic 6: MapReduce Applications
Topic 6: MapReduce ApplicationsTopic 6: MapReduce Applications
Topic 6: MapReduce Applications
 

Kürzlich hochgeladen

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Kürzlich hochgeladen (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

AOS Lab 5: System calls

  • 1. Lab 5: System calls Advanced Operating Systems Zubair Nabi zubair.nabi@itu.edu.pk February 27, 2013
  • 2. Normal execution of a processor While running a user process: 1 Read an instruction 2 Advance the program counter 3 Execute the instruction 4 Jump to 1
  • 3. Normal execution of a processor While running a user process: 1 Read an instruction 2 Advance the program counter 3 Execute the instruction 4 Jump to 1
  • 4. Normal execution of a processor While running a user process: 1 Read an instruction 2 Advance the program counter 3 Execute the instruction 4 Jump to 1
  • 5. Normal execution of a processor While running a user process: 1 Read an instruction 2 Advance the program counter 3 Execute the instruction 4 Jump to 1
  • 6. Normal execution of a processor While running a user process: 1 Read an instruction 2 Advance the program counter 3 Execute the instruction 4 Jump to 1
  • 7. Extraordinary events Events that break normal processor flow, to return control to the kernel: 1 A device signals that it needs attention (e.g. Timer): Interrupt 2 A user program does something illegal (e.g. divide by zero): Exception 3 A user program asks the kernel for a service: System call
  • 8. Extraordinary events Events that break normal processor flow, to return control to the kernel: 1 A device signals that it needs attention (e.g. Timer): Interrupt 2 A user program does something illegal (e.g. divide by zero): Exception 3 A user program asks the kernel for a service: System call
  • 9. Extraordinary events Events that break normal processor flow, to return control to the kernel: 1 A device signals that it needs attention (e.g. Timer): Interrupt 2 A user program does something illegal (e.g. divide by zero): Exception 3 A user program asks the kernel for a service: System call
  • 10. Extraordinary events Events that break normal processor flow, to return control to the kernel: 1 A device signals that it needs attention (e.g. Timer): Interrupt 2 A user program does something illegal (e.g. divide by zero): Exception 3 A user program asks the kernel for a service: System call
  • 11. Handling extraordinary events The operating system must: 1 Save the processor’s registers for future resumption 2 Set up system for execution in the kernel 3 Choose a place for the kernel to start execution 4 Retrieve information about the event and call corresponding interrupt handler 5 All the while, maintain isolation between user processes and the kernel
  • 12. Handling extraordinary events The operating system must: 1 Save the processor’s registers for future resumption 2 Set up system for execution in the kernel 3 Choose a place for the kernel to start execution 4 Retrieve information about the event and call corresponding interrupt handler 5 All the while, maintain isolation between user processes and the kernel
  • 13. Handling extraordinary events The operating system must: 1 Save the processor’s registers for future resumption 2 Set up system for execution in the kernel 3 Choose a place for the kernel to start execution 4 Retrieve information about the event and call corresponding interrupt handler 5 All the while, maintain isolation between user processes and the kernel
  • 14. Handling extraordinary events The operating system must: 1 Save the processor’s registers for future resumption 2 Set up system for execution in the kernel 3 Choose a place for the kernel to start execution 4 Retrieve information about the event and call corresponding interrupt handler 5 All the while, maintain isolation between user processes and the kernel
  • 15. Handling extraordinary events The operating system must: 1 Save the processor’s registers for future resumption 2 Set up system for execution in the kernel 3 Choose a place for the kernel to start execution 4 Retrieve information about the event and call corresponding interrupt handler 5 All the while, maintain isolation between user processes and the kernel
  • 16. Handling extraordinary events The operating system must: 1 Save the processor’s registers for future resumption 2 Set up system for execution in the kernel 3 Choose a place for the kernel to start execution 4 Retrieve information about the event and call corresponding interrupt handler 5 All the while, maintain isolation between user processes and the kernel
  • 17. Handling extraordinary events (2) • Need hardware support • On the x86, system calls generate an interrupt via the int instruction • The same mechanism for handling interrupts is used for handling system calls and exceptions • Traps are caused by the current running process • Interrupts are caused by devices • Can happen concurrently
  • 18. Handling extraordinary events (2) • Need hardware support • On the x86, system calls generate an interrupt via the int instruction • The same mechanism for handling interrupts is used for handling system calls and exceptions • Traps are caused by the current running process • Interrupts are caused by devices • Can happen concurrently
  • 19. Handling extraordinary events (2) • Need hardware support • On the x86, system calls generate an interrupt via the int instruction • The same mechanism for handling interrupts is used for handling system calls and exceptions • Traps are caused by the current running process • Interrupts are caused by devices • Can happen concurrently
  • 20. Handling extraordinary events (2) • Need hardware support • On the x86, system calls generate an interrupt via the int instruction • The same mechanism for handling interrupts is used for handling system calls and exceptions • Traps are caused by the current running process • Interrupts are caused by devices • Can happen concurrently
  • 21. Handling extraordinary events (2) • Need hardware support • On the x86, system calls generate an interrupt via the int instruction • The same mechanism for handling interrupts is used for handling system calls and exceptions • Traps are caused by the current running process • Interrupts are caused by devices • Can happen concurrently
  • 22. Handling extraordinary events (2) • Need hardware support • On the x86, system calls generate an interrupt via the int instruction • The same mechanism for handling interrupts is used for handling system calls and exceptions • Traps are caused by the current running process • Interrupts are caused by devices • Can happen concurrently
  • 23. x86 protection • 4 protection levels: 0 to 3 • Privilege decreases in ascending order • Most operating systems only use 2 levels: 0 (kernel mode) and 3 (user mode) • Interrupt handlers are defined in an interrupt descriptor table (idt) with a total of 256 entries • int n generates a system call, where n is used to index the idt • It is the job of the operating system to implement a handler for each entry in the idt
  • 24. x86 protection • 4 protection levels: 0 to 3 • Privilege decreases in ascending order • Most operating systems only use 2 levels: 0 (kernel mode) and 3 (user mode) • Interrupt handlers are defined in an interrupt descriptor table (idt) with a total of 256 entries • int n generates a system call, where n is used to index the idt • It is the job of the operating system to implement a handler for each entry in the idt
  • 25. x86 protection • 4 protection levels: 0 to 3 • Privilege decreases in ascending order • Most operating systems only use 2 levels: 0 (kernel mode) and 3 (user mode) • Interrupt handlers are defined in an interrupt descriptor table (idt) with a total of 256 entries • int n generates a system call, where n is used to index the idt • It is the job of the operating system to implement a handler for each entry in the idt
  • 26. x86 protection • 4 protection levels: 0 to 3 • Privilege decreases in ascending order • Most operating systems only use 2 levels: 0 (kernel mode) and 3 (user mode) • Interrupt handlers are defined in an interrupt descriptor table (idt) with a total of 256 entries • int n generates a system call, where n is used to index the idt • It is the job of the operating system to implement a handler for each entry in the idt
  • 27. x86 protection • 4 protection levels: 0 to 3 • Privilege decreases in ascending order • Most operating systems only use 2 levels: 0 (kernel mode) and 3 (user mode) • Interrupt handlers are defined in an interrupt descriptor table (idt) with a total of 256 entries • int n generates a system call, where n is used to index the idt • It is the job of the operating system to implement a handler for each entry in the idt
  • 28. x86 protection • 4 protection levels: 0 to 3 • Privilege decreases in ascending order • Most operating systems only use 2 levels: 0 (kernel mode) and 3 (user mode) • Interrupt handlers are defined in an interrupt descriptor table (idt) with a total of 256 entries • int n generates a system call, where n is used to index the idt • It is the job of the operating system to implement a handler for each entry in the idt
  • 29. x86 protection • 4 protection levels: 0 to 3 • Privilege decreases in ascending order • Most operating systems only use 2 levels: 0 (kernel mode) and 3 (user mode) • Interrupt handlers are defined in an interrupt descriptor table (idt) with a total of 256 entries • int n generates a system call, where n is used to index the idt • It is the job of the operating system to implement a handler for each entry in the idt
  • 30. int • Fetches the nth descriptor from idt • Ensures that the privilege level in the descriptor is 3 • As the interrupt is due to a user process, saves the process state (change in privilege level) • Sets the instructor pointer to the required starting address in the descriptor table and starts execution • After execution, the OS calls iret to resume previous execution state
  • 31. int • Fetches the nth descriptor from idt • Ensures that the privilege level in the descriptor is 3 • As the interrupt is due to a user process, saves the process state (change in privilege level) • Sets the instructor pointer to the required starting address in the descriptor table and starts execution • After execution, the OS calls iret to resume previous execution state
  • 32. int • Fetches the nth descriptor from idt • Ensures that the privilege level in the descriptor is 3 • As the interrupt is due to a user process, saves the process state (change in privilege level) • Sets the instructor pointer to the required starting address in the descriptor table and starts execution • After execution, the OS calls iret to resume previous execution state
  • 33. int • Fetches the nth descriptor from idt • Ensures that the privilege level in the descriptor is 3 • As the interrupt is due to a user process, saves the process state (change in privilege level) • Sets the instructor pointer to the required starting address in the descriptor table and starts execution • After execution, the OS calls iret to resume previous execution state
  • 34. int • Fetches the nth descriptor from idt • Ensures that the privilege level in the descriptor is 3 • As the interrupt is due to a user process, saves the process state (change in privilege level) • Sets the instructor pointer to the required starting address in the descriptor table and starts execution • After execution, the OS calls iret to resume previous execution state
  • 35. The first system call • Recall that initcode.S started off by invoking an exec system call to load the init process (/init) • Flow: 1 Push the arguments and binary for exec on the process’s stack 2 Put the system call number (SYS_exec) in %eax (obviously this number should already be present in the system call table, *syscalls[]) 3 Execute int T_SYSCALL
  • 36. The first system call • Recall that initcode.S started off by invoking an exec system call to load the init process (/init) • Flow: 1 Push the arguments and binary for exec on the process’s stack 2 Put the system call number (SYS_exec) in %eax (obviously this number should already be present in the system call table, *syscalls[]) 3 Execute int T_SYSCALL
  • 37. The first system call • Recall that initcode.S started off by invoking an exec system call to load the init process (/init) • Flow: 1 Push the arguments and binary for exec on the process’s stack 2 Put the system call number (SYS_exec) in %eax (obviously this number should already be present in the system call table, *syscalls[]) 3 Execute int T_SYSCALL
  • 38. The first system call • Recall that initcode.S started off by invoking an exec system call to load the init process (/init) • Flow: 1 Push the arguments and binary for exec on the process’s stack 2 Put the system call number (SYS_exec) in %eax (obviously this number should already be present in the system call table, *syscalls[]) 3 Execute int T_SYSCALL
  • 39. The first system call • Recall that initcode.S started off by invoking an exec system call to load the init process (/init) • Flow: 1 Push the arguments and binary for exec on the process’s stack 2 Put the system call number (SYS_exec) in %eax (obviously this number should already be present in the system call table, *syscalls[]) 3 Execute int T_SYSCALL
  • 40. x86 traps • 256 different interrupts • 0-31 software • 32-63 hardware • 64 system calls (T_SYSCALL)
  • 41. x86 traps • 256 different interrupts • 0-31 software • 32-63 hardware • 64 system calls (T_SYSCALL)
  • 42. x86 traps • 256 different interrupts • 0-31 software • 32-63 hardware • 64 system calls (T_SYSCALL)
  • 43. x86 traps • 256 different interrupts • 0-31 software • 32-63 hardware • 64 system calls (T_SYSCALL)
  • 44. Setting up idt • tvinit, called from main, sets up the entries in idt • The address of the handler for each interrupt in idt is present in vectors[], i.e. Interrupt i is handled by vectors[i] • T_SYSCALL is handled specially: it is distinguished as a trap allowing multiple system calls to execute simultaneously
  • 45. Setting up idt • tvinit, called from main, sets up the entries in idt • The address of the handler for each interrupt in idt is present in vectors[], i.e. Interrupt i is handled by vectors[i] • T_SYSCALL is handled specially: it is distinguished as a trap allowing multiple system calls to execute simultaneously
  • 46. Setting up idt • tvinit, called from main, sets up the entries in idt • The address of the handler for each interrupt in idt is present in vectors[], i.e. Interrupt i is handled by vectors[i] • T_SYSCALL is handled specially: it is distinguished as a trap allowing multiple system calls to execute simultaneously
  • 47. tvinit 1 2 3 4 5 6 7 8 9 10 11 12 13 14 void tvinit (void) { int i; for(i = 0; i < 256; i++) SETGATE (idt[i], 0, SEG_KCODE <<3, vectors [i], 0); SETGATE (idt[ T_SYSCALL ], 1, SEG_KCODE <<3, vectors [ T_SYSCALL ], DPL_USER ); /∗ SETGATE (gate , istrap , sel , off , d) ∗ ∗ ∗ ∗ ∗ gate: idt entry istrap : 1 trap , 0 interrupt sel: code segment off: offset within code segment d: privilege level ∗/ initlock (& tickslock , "time"); }
  • 48. Addresses of interrupt handlers • xv6 uses a custom Perl script vectors.pl to generate vectors.S which holds entry points of interrupt handlers in vectors[] • Each entry point: Pushes an error code Pushes the interrupt number 3 Jumps to alltraps 1 2
  • 49. Addresses of interrupt handlers • xv6 uses a custom Perl script vectors.pl to generate vectors.S which holds entry points of interrupt handlers in vectors[] • Each entry point: Pushes an error code Pushes the interrupt number 3 Jumps to alltraps 1 2
  • 50. Addresses of interrupt handlers • xv6 uses a custom Perl script vectors.pl to generate vectors.S which holds entry points of interrupt handlers in vectors[] • Each entry point: Pushes an error code Pushes the interrupt number 3 Jumps to alltraps 1 2
  • 51. Addresses of interrupt handlers • xv6 uses a custom Perl script vectors.pl to generate vectors.S which holds entry points of interrupt handlers in vectors[] • Each entry point: Pushes an error code Pushes the interrupt number 3 Jumps to alltraps 1 2
  • 52. alltraps 1 Pushes all processor registers into a struct trapframe • Once the call completes, the kernel can restore state from this structure 2 Sets up the processor to run kernel C code (load SEG_KCPU, per-CPU data segment) 3 Calls the C trap handler trap 4 Once trap returns, alltraps restores struct trapframe and then calls iret to return control back to user space
  • 53. alltraps 1 Pushes all processor registers into a struct trapframe • Once the call completes, the kernel can restore state from this structure 2 Sets up the processor to run kernel C code (load SEG_KCPU, per-CPU data segment) 3 Calls the C trap handler trap 4 Once trap returns, alltraps restores struct trapframe and then calls iret to return control back to user space
  • 54. alltraps 1 Pushes all processor registers into a struct trapframe • Once the call completes, the kernel can restore state from this structure 2 Sets up the processor to run kernel C code (load SEG_KCPU, per-CPU data segment) 3 Calls the C trap handler trap 4 Once trap returns, alltraps restores struct trapframe and then calls iret to return control back to user space
  • 55. alltraps 1 Pushes all processor registers into a struct trapframe • Once the call completes, the kernel can restore state from this structure 2 Sets up the processor to run kernel C code (load SEG_KCPU, per-CPU data segment) 3 Calls the C trap handler trap 4 Once trap returns, alltraps restores struct trapframe and then calls iret to return control back to user space
  • 56. alltraps 1 Pushes all processor registers into a struct trapframe • Once the call completes, the kernel can restore state from this structure 2 Sets up the processor to run kernel C code (load SEG_KCPU, per-CPU data segment) 3 Calls the C trap handler trap 4 Once trap returns, alltraps restores struct trapframe and then calls iret to return control back to user space
  • 57. trap • Gets passed struct trapframe *tf • Checks tf->trapno to decide if it was called for a system call (T_SYSCALL) or a hardware interrupt or an exception • In case of: 1 System call, it invokes syscall 2 3 Hardware interrupt, it calls the hardware interrupt controller Exception, it prints the details and kills the user process
  • 58. trap • Gets passed struct trapframe *tf • Checks tf->trapno to decide if it was called for a system call (T_SYSCALL) or a hardware interrupt or an exception • In case of: 1 System call, it invokes syscall 2 3 Hardware interrupt, it calls the hardware interrupt controller Exception, it prints the details and kills the user process
  • 59. trap • Gets passed struct trapframe *tf • Checks tf->trapno to decide if it was called for a system call (T_SYSCALL) or a hardware interrupt or an exception • In case of: 1 System call, it invokes syscall 2 3 Hardware interrupt, it calls the hardware interrupt controller Exception, it prints the details and kills the user process
  • 60. trap • Gets passed struct trapframe *tf • Checks tf->trapno to decide if it was called for a system call (T_SYSCALL) or a hardware interrupt or an exception • In case of: 1 System call, it invokes syscall 2 3 Hardware interrupt, it calls the hardware interrupt controller Exception, it prints the details and kills the user process
  • 61. trap • Gets passed struct trapframe *tf • Checks tf->trapno to decide if it was called for a system call (T_SYSCALL) or a hardware interrupt or an exception • In case of: 1 System call, it invokes syscall 2 3 Hardware interrupt, it calls the hardware interrupt controller Exception, it prints the details and kills the user process
  • 62. syscall • Loads the system call number through proc->tf->eax • Calls the corresponding system call from the syscalls table • Puts its return value in proc->tf->eax (available on return to user space) • Conventionally negative numbers indicate errors while positive ones indicate success • System call arguments are retrieved using either argint, argptr, or argstr
  • 63. syscall • Loads the system call number through proc->tf->eax • Calls the corresponding system call from the syscalls table • Puts its return value in proc->tf->eax (available on return to user space) • Conventionally negative numbers indicate errors while positive ones indicate success • System call arguments are retrieved using either argint, argptr, or argstr
  • 64. syscall • Loads the system call number through proc->tf->eax • Calls the corresponding system call from the syscalls table • Puts its return value in proc->tf->eax (available on return to user space) • Conventionally negative numbers indicate errors while positive ones indicate success • System call arguments are retrieved using either argint, argptr, or argstr
  • 65. syscall • Loads the system call number through proc->tf->eax • Calls the corresponding system call from the syscalls table • Puts its return value in proc->tf->eax (available on return to user space) • Conventionally negative numbers indicate errors while positive ones indicate success • System call arguments are retrieved using either argint, argptr, or argstr
  • 66. syscall • Loads the system call number through proc->tf->eax • Calls the corresponding system call from the syscalls table • Puts its return value in proc->tf->eax (available on return to user space) • Conventionally negative numbers indicate errors while positive ones indicate success • System call arguments are retrieved using either argint, argptr, or argstr
  • 67. Reading(s) • Chapter 3, “Traps, interrupts, and drivers”, till section “Code: System calls" from “xv6: a simple, Unix-like teaching operating system”