Operating System : System Calls - SciComp

Post Top Ad

Responsive Ads Here

Operating System : System Calls

Share This

SYSTEM CALLS:

It provides an interface to the services made available by the operating system. Application developers design programs according to an application programming interface(API). API defines a set of functions that are available to an application programmers. This includes the parameters passed to function & return values the programmer can accept. WIN 32 API, POSIX API, JAVA API are the most common API’s.

The functions that make up an API typically invokes the actual system calls on behalf of the application programmer.

SOURCE FILE ------------------------------------------------------------------------------ DESTINATION FILE                                                                                                  

                                          Example System Call Sequence

Acquire input file name
Write prompt to screen
Accept input
Acquire output file name
Write prompt to screen
Accept input
Open the  input file
If file doesn’t exists, abort
Create output file
If file exists, abort
Loop
Read from input file
Write to output file
Until read fails
Close output file
Write completion message to screen
Terminate normally


Benefits of programming according to API

·Programming portability

·Actual system calls are more detailed & more difficult to work with that API available to the programmer.

·Run time Support System (set of functions built into libraries included with a compiler) provides system call interface that serves as a link to system calls made available by the OS.

·System calls interface intercepts function calls in the API & invokes necessary system calls within the OS.

System calls provides the interface between a process and the OS. These calls are generally available as the assembly language instruction.

Methods of passing parameters to OS:

·        Pass parameters through registers.

·        Storing parameters in blocks and passing the address through registers.

·        Parameters can ne pushed into stack by program and popped off by the OS.

The block or stack method do not limit the number or length of parameters being passed.


TYPES OF SYSTEM CALLS :

1.    Process control:

·        End, abort

·        Load, execute

·        Create process, terminate process

·        Get process attributes, set process attributes

·        Wait for time

·        Wait event, signal event

·        Allocate & free memory

2.    File Management:

·        Create file, delete file

·        Open, close

·        Read, write, reposition

·        Get file attributes, set file attributes

3.    Device management:

·        Request device, release device

·        Read, write, reposition

·        Get device attribute, set device attribute

4.    Information maintenance:

·        Get time or date, set time or date

·        Get system data, set system data

·        Get process, file or device attribute

·        Set process, file or device attribute

5.    Communications:

·        Create, delete communication connection

·        Send, receive messages

·        Transfer status information

·        Attach or detach remote devices

Two common models of Inter Process Communication:

·        Message passing model

·        Shared memory model

6.    Protection:

Provides a  mechanism for controlling access to the resources provided by the system.

·        Get file security status, set file security status

·        Allow user, deny user

·        Set file security group

Example of Windows and UNIX system calls :

                                                                    Windows                                                      UNIX

Process                                              CreateProcess()                                                         fork()

Control                                           ExitProcess()                                                               exit()  

                                                       WaitForSingleObject()                                                wait()

File                                                 CreateFile()                                                                 open()

Manipulation                                  ReadFile()                                                                  read()

                                                       WriteFile()                                                                   write()

                                                       CloseHandle()                                                              close()

Device                                           SetConsoleMode()                                                       ioctl()

Manipulation                                ReadConsole()                                                         read()

                                                      WriteConsole()                                                             write()

Information                                  GetCurrentProcessID()                                                 getpid()

Maintenance                                 SetTimer()                                                                    alarm()

                                                      Sleep()                                                                          sleep()

Communication                            CreatePipe()                                                                  pipe()

                                                      CreateFileMapping()                                                shm open()

                                                      MapViewOfFile()                                                          mmap()

Protection                                     SetFileSecurity()                                                               chmod()

                                                      InitlializeSecurityDescriptor()                                           umask()

                                                       SetSecurityDescriptorGroup()                                         chown()

No comments:

Post a Comment

Post Bottom Ad

Responsive Ads Here

Pages