0% found this document useful (0 votes)
29 views

Operating Systems Design: Session 3: OS Interface

The document discusses the operating system interface, including user interface types like command line and graphical interfaces. It covers virtualization mechanisms like time-sharing and partitioning resources. Key system calls for processes are discussed like fork, wait, exit and exec. I/O and file descriptors, pipes, and the file system are also summarized.

Uploaded by

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

Operating Systems Design: Session 3: OS Interface

The document discusses the operating system interface, including user interface types like command line and graphical interfaces. It covers virtualization mechanisms like time-sharing and partitioning resources. Key system calls for processes are discussed like fork, wait, exit and exec. I/O and file descriptors, pipes, and the file system are also summarized.

Uploaded by

Avinash Alla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

19CS2106R​

Operating Systems Design ​


Session 3 : OS Interface

© 2020 KL University
Operating System User Interface
Operating System User Interface
• A program that controls a display for the user (usually on a computer
monitor) and that allows the user to interact with the system) .
• The user interface allows the user to communicate with the operating
system.
• Types of User Interface
• Command line interface
• Graphical user interface
Comparison
• Ease of Use/Learning
• Control on File System/Operating System
• Multitasking
• Speed of Operating
Operating System Hardware Interface
Abstracting physical resources
• A key requirement for an operating system is to support several
activities at once.
• An operating system must fulfil three requirements:
• Multiplexing
• Isolation
• Interaction.
• Operating System does this through Virtualization
• Virtualization refers to process involved in converting a physical view to
a logical view. 
• The logical view is the view of the application programmer.
• The physical view refers to the actual physical state of affairs.
Virtualization Mechanisms
• There are two general mechanisms for giving the appearance of
multiple instances of a resource where there is physically only one
resource.
• Time-Shared Resources
• Processors, mice, keyboards, printers and network connections are
time shared between processes. 
• Partitioned Resources
• Memory, displays, and disks are partitioned resources.
• These resources are partitioned into "pieces" that are assigned to
individual processes.
User mode, Kernel mode and System calls
Strong isolation requires a hard boundary
between applications and the operating
system.
• An application can execute only user-mode instructions (e.g., adding
numbers, etc.) and is said to be running in user space, .
• The software in kernel mode can also execute privileged instructions and
is said to be running in kernel space.
• The software running in kernel space (or in kernel mode) is called the
kernel.
• When a process needs to invoke a kernel service, it invokes a procedure
call (system call) in the operating system interface.
Process Management
• A process is the execution of a program.
• The kernel identifies each process by its process number, called
the process ID (PID).
• A process has Instructions, data and stack in User space.
• The instructions implement the program’s computation.
• The data are the variables on which the computation acts.
• The stack organizes the program’s procedure calls.
• Kernel stores the State of every process in Kernel space.
XV6 Interface Design Concepts
XV6 Interface
• Shell is the primary user interface to traditional Unix-like systems
including XV6.
• The shell is an ordinary program(user level) that reads commands from
the user and executes them.
• The xv6 shell is a simple implementation of the essence of the Unix
Bourne shell.
• XV6 Kernel
• Process Management
• I/O Management
• File System Management
XV6
System Calls
Processes and memory fork() – Creating a Process
• A process on a UNIX system is the entity that is created by
the fork system call.
• Fork creates a new process, called the child process, with exactly the
same memory contents as the calling process, called the parent
process.
• Every process except process 0 is created when another process
executes the fork system call.
• Process 0 is a special process that is created "by hand" when the system
boots; after forking a child process (process 1), process 0 becomes
the swapper process.
• Process 1, known as init is the ancestor of every other process.
Processes and memory fork() – Creating a Process
• fork() is used to create processes. It takes no arguments and returns a
process ID
• The purpose of fork() is to create a new process, which becomes
the child process of the caller.
• After a new child process is created, both processes will execute the
next instruction following the fork() system call. 
• If fork() returns a negative value, the creation of a child process was
unsuccessful.
• fork() returns a zero to the newly created child process.
• fork() returns a positive value, the process ID of the child process, to
the parent. 
Processes and memory fork() – Creating a Process
The fork() System Call

24667 24668

pid =24668 pid =0


Processes and memory Wait() and exit()

• The system call wait() blocks the calling process until one of


its child processes exits or a signal is received. 
• The exit system call causes the calling process to stop executing and to
release resources such as memory and open files.
• Exit takes an integer status argument, conventionally 0 to indicate
success and 1 to indicate failure.
fork(), wait() and exit() usage
Processes and memory example
int pid = fork();
if(pid > 0){
printf("parent: child=%d\n", pid);
pid = wait(); parent: child=1234
printf("child %d is done\n", pid); child: exiting
} else if(pid == 0){ parent: child 1234 is done
printf("child: exiting\n");
exit();
} else {
printf("fork error\n");
}
Processes and memory exec()

• The exec system call replaces the calling process’s memory with a new
memory image loaded from a file stored in the file system.
• The created child process does not have to run the same program as
the parent process does.
• fork starts a new process which is a copy of the one that calls it, while
exec replaces the current process image with another (different) one.
• Both parent and child processes are executed simultaneously in case
of fork() while Control never returns to the original program unless
there is an exec() error.
I/O and File descriptors
• A file descriptor is a small integer representing a kernel-managed
object that a process may read from or write to.
• A file descriptor interface abstracts away the differences between
files, pipes, and devices, making them all look like streams of bytes.
• The read and write system calls read bytes from and write bytes to
open files named by file descriptors.
• The call read(fd, buf, n) reads at most n bytes from the file descriptor
fd, copies them into buf, and returns the number of bytes read.
• The call write(fd, buf, n) writes n bytes from buf to the file descriptor
fd and returns the number of bytes written.
• The close system call releases a file descriptor, making it free.
Pipes
• A pipe is a small kernel buffer exposed to processes as a pair of file
descriptors, one for reading and one for writing.
• Writing data to one end of the pipe makes that data available for
reading from the other end of the pipe.
• Pipes provide a way for processes to communicate
File System
• The xv6 file system provides data files, which are uninterpreted byte
arrays, and directories, which contain named references to data files
and other directories.
• The directories form a tree, starting at a special directory called the
root.
• Paths that don’t begin with / are evaluated relative to the calling
process’s current directory, which can be changed with the chdir
system call.
• There are multiple system calls to create a new file or directory: mkdir
creates a new directory, open with the O_CREATE flag creates a new
data file, and mknod creates a new device file.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy