System Calls Function Hardware Resources Computer Science Essay

Published: Last Edited:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

Computer system manages the hardware resources of a computer in the usual manners. It is an interface between user programs and the computers hardware resources. Users program can execute programs, use memory, Input/Output(I/O), File Management using the operating system platform. Basically, Operating system can be explains as the continuous running process/program on the computers system. Usually, Operating system has a user interface, either command line or Graphical User Interface.

Mostly Windows and UNIX operating system have kernels. The basic functionality of the operating system can be provided by kernel. Mostly, The kernel provides Process management, memory management, Thread management, I/O management and power management.

Basically, in UNIX, System call can be represented by API functions. System calls are interface for programming basically, similar to all implementation of UNIX. A set of API functions can be represented by kernels that are used by different processes through system calls.

Usually, systems calls are use to call the kernel for to execute a specific task that controls devices and also executes a instruction. The ways system calls can be handled up to the processor. Mostly, system call to the kernel is due to an interrupt or exception; a call has a request to execute something. For example, the serial port may be programmed to assert an interrupt when some character has arrived, instead of polling for it. This is the actual ways one processor can be used by other processes and service the serial port only when it is needed.

UNIX is a monolithic kernel, describes as the process, memory, devices and file mangers are implemented in a single s/w module. The devices driver which is the part of device management is implemented in separate modules, but all other managers are in one big program.

Whereas, the windows NT Operating system is logically layered with a hardware abstraction layer, NT kernel, NT executive and various subsystems on top of the NT executive. The Win 32 API system call interface that is exported by the win32 subsystem. The OS kernel is separated by I/O subsystem, and contains the devices drivers

What are system calls giving brief example

 The following table briefly describe the function of each system calls on UNIX.

System calls Function

Open Open an existing file or create a new file.

Read To read data from a file.

Write To write data to a file.

Lseek To Move the R/W pointer to the specified location/.

Close To close an open file.

Unlink To delate a file.

Chmod To Change the file protection attributes.

stat To read file information from inodes.

The following functions are Windows 98/Me and Windows NT/2000/XP operating-system calls.

System Call Functions

_findclose Release resources from previous find operations

_findfirst, _findfirst64, _find firsti64, _wfindfirst, _wfindfirst64, _wfindfirsti64 Find file with specified attributes.

_findnext, _findnext64, _findnexti64, _wfindnext, _wfindnext64, _wfindnexti64 Find next

User Interfaces

Basically, the way of communicating among the clients, applications and the computer is user interfaces.

The UNIX user interface was originally related on a character- oriented cmd line, but the windows user interface was based on Graphical user interface(GUI). Unix was originated when graphical terminals were not available. But, the recent versions of UNIX support the graphical user interface (GUI) using the X windows system. The common windowing system,library and user interface style built on X Windows is Motif. Motif allows the building of GUI applications on UNIX.

The windows user interface was designed to take advantage of graphics capabilities of computers. It also can be used by all applications in both cliend side and the server side and it also can be used for tasks such as service has the graphics device interface(GDI) engine to support the GUI.

Example of Command Line Interface

Example of GUI

Process handling

Basically, a process can be explains as the instance of running program. And also process management represents how OS manages the multiple process at a specific period of time. The operating system such as Windows and UNIX are the multitasking operating system mostly manages and control many processes simultaneously. UNIX and Windows both supports threads and processes.

The more detail descriptions on process management in UNIX and windows are as follows:

Process hierarchy:-

 When a UNIX-based application creates a new process, the new process becomes a child of the process that created it. This process hierarchy is often important, and there are system calls for manipulating child processes.

Unlike UNIX, Windows processes do not share a hierarchical relationship. The creating process receives the process handle and ID of the process it created, so a hierarchical relationship can be maintained or simulated if required by the application. However, the operating system treats all processes like they belong to the same generation. Windows provides a feature called Job Objects, which allows disparate processes to be grouped together and adhere to one set of rules.

Process management involved:-

- To create a new process

-To replace a process image

-To maintain process hierarchy

-To Wait for a child process

-To manage process resource limits

- To support process groups

-To manage and schedule the processes

Usually, process management system call are as follows:

Pid= fork() fork a new process.

Pid= waitpid(pid, static, opts) It Waits until one of the children processes die and return its processidentity(pid) and termination.

S=execve( name, argv, envp) Same as execv, except that the third argument provides the environment to the program executed.

Exit(status) Execution process terminates and return status.

Size= brk(addr) To set the size of the data segment.

Pid=getpid() Return the pid of the process

Pid=setsid() To create a new session and return its pid

L=strace( req,pid, addr, date) Used for debugging

S=sigaction(sig,act,&oldact) Define action to take on signals

S=sigreturn(&context) To return from a signal

S=sigprocmask(how,&set,&oldact) Examine or change the signal mask

S=sigpending((set) To Get the set of blocked signals

S=sigpending(set) To Replace the signal mask and suspend the process

S=kill(pid, sig) To send a signal to a process

Residual= alarm(seconds) To set the alarm clock

S=pause() To suspend the caller until the next signal.

If you have a look at the UNIX system calls dealing with process management

The system call fork() is a good example to start the topic of discussion. Fork() is only one way to create a new process in UNIX systems. Fork() create the child process exact identical to the parent process including the file descriptors , registers and others else. After the fork() , parent process and the child process go to separate ways. And also all the variables have identical values at the time of the fork, but since the entire parent is copied to create the child, some changes in one do not affect the other one. The fork() system calls return certain values which is zero in the child, and equal to the child's process ID in the parent. The returned ProcessID, the two processes can see one is parent and \other one is the child

Memory management:-

Usually, Memory management has always been one of the most important and interesting aspects specially for developer of any operating system like UNIX , windows has the standard heap managment functions, also the functions to manage memory on a thread basis.

Heap:- Heap is an certain space of memory which is separate from the program code and the stack. Basically, heaps reserved for the allocation of the certain memory need for the program that windows operating system provides similar to UNIX with respect to heap management. The standard called C runtime in windows operating system includes comparable functions for like UNIX functions as calloc,malloc,realloc and free. But windows has many more additional functions that may not be available in UNIX Operating system, these are try to covered shortly in the following sections:-

Thread local storage:- It is another space of memory management that defines memory as on a per-thread basis. All the threads of certain processes shares its virtual address space, whereas the static and the global variables are shared by all the threads in the process, and the local variables of a certain functions are unique to each thread that runs the functions. Each thread that the process accesses by using a global index can provides unique data by TLS. The thread having allocates the index, which also can be used by other threads to retrieve the data associated with it.

The functions usually used for to manage TLS in UNIX and Windows are as follows:

Allocating memory:-

Allocating memory involve the TlsAlloc function allocates a TLS index. A Thread local storage(TLS) index is basically used by a thread to store and retrieve values that are local to the thread. TLS_MINIMUM_AVAILABLE is defined to indexes the minimum number of available to each process. Also the TLS indexes are not valid for process boundaries. The example of the function is as follows:

DWORD TlsAlloc(void);

In case of UNIX, pthread_key_create which create a thread-specific data key which is visible to all the threads of the process. Under the key creation, the NULL value is associated with the new key in all active threads. And also an optional destructor function also may be associated with every key value. The example ot the function is as follow:

Int pthread_key_create(pthread_key_t *key,

Void (* destructor, void*));

Deleting memory:-

In case of windows, Tlsfree release a index TLS. But this doesnot release the data allocated and set in the TLS index slot.The example of the function is as follows:

BOOL TlsFree(DWORD dwTlsIndex);

However, In the case of UNIX , the pthread_key_delate function which delates the thread-specific data key.

Int pthread_key_delate(pthread_key_t key);

Storing a value:-

In case of Windows Environment, The TlsSetValue function is used to stores in the memory in a TLS Index. The example of the function is as follows:

BOOL TlsSetValue(DWORD dwTlsindex,LPVOID IPTlsValue);

In the case of UNIX, The pthread_setspecific function is associates a thread-specific value with the key. The example of the function is as follow:

Int pthread_setspecific(pthread_key_t key, const void* value);

Security: -

Security differences between UNIX and the windows are as follows:

User authentication:- basically, users can log on to a system running UNIX operating system by using valid username and the password. Usually, a UNIX user can be local to the system or known on the network Information system(NIS) domain represents a group of cooperating computers. Mostly, the NIS( network Information system) database contains more then username, password and group.

Moreover, A user can log on to a system running windows operating system by simply entering a valid username and the password. Also, a windows user can be local to the system/computer, explain as windows domain, or also known in the Microsoft active Directory. Usually, the windows domain contains a valid username, password, and some user groups. The windows domain contains the same information as Microsoft active directory and active directory may contain the contact information of the user, organizational data, and certificates.

UNIX versus windows security. UNIX has a simple security system. Usually, operating system applies security by assigning permissions to access files. This security system usually works because UNIX uses files to represent devices, memory, and also to processes. When a user logs on to the system with a username and passwords. UNIX operating system starts a shell with the UID and GID of specific user. After that the permissions assigned to that UID and GID, or also the processes, controls all access to files & resources.

In the windows environment, its uses a unified security model that controls all object from unauthorized access. The windows system maintains security information for users, objects and active directory:

Users:- The users of system are people who log on to the computer, either entering a set of typically username and password or remotely through the network access. Each user's security instruction is represented by a logon session.

Objects:- The secured resources such as files, computers, synchronization objects and applications that can access by a user are the objects.

Active Directory:- In windows server 2003, Active Directory service is to store information about objects. These objects such as users, computers, printers & domains on one or more (WANs). The active directory can scale from a system to many systems on the networks. Basically, its provides a store for all the domain security policy and account information.


Security System calls in UNIX are as follows:

S=chmod(name,mode) To changes files protection bits

Uid=getuid() To get the caller's uid

Gid=getgid() To get the caller's uid

S=setuid(uid) To set the caller's uid

S=setgid(gid) To set the caller's uid

S=chown(name, owner,group) change a files owner an group

Oldmask=umask(complmode) Change the mode mask


Basic system calls for input/output in UNIX:-

File Descriptors

The abstract type of file descriptors.

value stdin : file_descriptor

value stdout : file_descriptor

value stderr : file_descriptor

File descriptors for standard input, standard output and standard error.

type open_flag =

O_RDONLY To open for reading

O_WRONLY To open for writing.

O_RDWR To open for reading and writing.

O_NDELAY To open in non- blocking mode.

O_APPEND To open for Append

O_CREAT To create if non existent.

O_TRUNC It truncate to 0 length if existing.

O_EXCL failed if existing.

The flags to open.

type file_perm == int

The type of file access rights.

value open : string -> open_flag list -> file_perm -> file_descr

Open the named file with the given flags. Third argument is the permissions to give to the file if it is created. Return a file descriptor on the named file.

value close : file_descr -> unit

Close a file descriptor.

value read : file_descr -> string -> int -> int -> int

read fd buff start len reads len characters from descriptor fd, storing them in string buff, starting at position ofs in string buff. Return the number of characters actually read.

value write : file_descr -> string -> int -> int -> int

write fd buff start len writes len characters to descriptor fd, taking them from string buff, starting at position ofs in string buff. Return the number of characters actually written.

Interfacing with the standard input/output library.

value in_channel_of_descr : file_descr -> in_channel

Use to create an input channel reading from the given descriptor.

value out_channel_of_descr : file_descr -> out_channel

Use to create an output channel writing on the given descriptor.

value descr_of_in_channel : in_channel -> file_descr

Use to return the descriptor corresponding to an input channel.

value descr_of_out_channel : out_channel -> file_descr

Use to return the descriptor corresponding to an output channel.

System calls Window operating system:-

Append to directory listing

If multiple listing are to be concatenated append. Without APPend an existing dirList is replaced.

Nfiles= SYSTEM(DIR="*.lst", FILE=dirlist, APPend)

! append lst files of current folder to dirlist



File command in the same statement: Create a Directory listing

Keywords DIR and FILE are both required to get a listing of some or all of the

file in a directory.

DIR= TXT is a filter argument to select all or only part of the filenames.FILE=txt is a file name to get the resulting list.

Nfiles= SYSTEM (DIR="*.txt",FILE=dirList)! Txt files of current folder to dirList,-

Edit dirList

To edit directory list

Open dirList(1 column isolated by quotes, 5 columns by commas)

OPEN(FILe=dirList, Format="",5F,')

DLG(Edit=dirList, Format="A8,i12,z4,3UWWW YY-MM-DD HH:mm")

Read selected directory element

With the above OPEN statement is easy:

Name3= dirList(3,1)

Created8= dirlist(8,4)

Start other programs with


Shell cmds are case sensitive.

Basically, Shell command never waits for termination

To wait for termination of the called program use the RUN command

To wait for termination of the called program use the RUN

Email client open

SYSTEM( ?subject=hello&BOD Y=text)

Browser open


Window Explorer open

SYSTEM(shell="c:\new folder")




To set the working directory for the called program



Allowed modes are"","edit","print","open"


Other program start wait with the



System(RUN="c:\Windows|notepad.exe mytext.txt")

File Management:-

The file management includes the differences in file handling, file access, file control, and directory operations. In UNIX and windows applications, you can use this information for better understand.

Those Programs that runs from the UNIX shell opens three standard files. These files have file descriptors of integer, which provides the primary communications between the applications, and also it exist for as long as the run process. You can associate other file descriptors with devices and file suing the open system call.

The UNIX standard file descriptors are listed below.

UNIX standard file descriptors

File File descriptor Description

Standard input 0 It shows a way to send data to a process. By default, the standard input is read from the keyboard.

Standard Output 1 It shows a means for the program to output the data. The standard output goes to the result by default.

Standard error 2 The standard error include the error reports that occurred during the program execution. By default, the

In windows, A program get start execution, the startup code automatically opens the following files

- Standard input( pointed to by stdin)

- Standard output( pointed to by stdout)

- Standard error(pointed to by stderr)

These files are directed to the console(keyboard & screen) by default. Use freopen to redirect stdin, stdout, or stderr to a disk file or a device.

The stdout and stderr stream files are flushed whenever they are full or, if you are writing to a character device, after each library call. If a program terminates abnormally, output buffers may not be flushed, resulting in loss of data. Use fflush or _flushall to ensure that the buffer associated with a specified file or that all open buffers are flushed to the operating system, which can cache data before writing it to disk. The commit-to-disk feature ensures that the flushed buffer content is not lost in the event of a system failure.

File management system calls in UNIX are as follows:

Create(name, mode) To create a new file

Mknod(name,mode,addr) To create a regular, special, or directory i-node

Open(file,how,..) Open a file for reading, writing or both

S= Close(fd) Close an open file

n=read(fd, buffer, nbytes) To read data from a file into a buffer

n= write(fd, buffer,nbytes) write data from a buffer to a file.

Pos= lseek(fd,offset, whence) Move the file pointer

S= stat(name,& buf) To get a file's status information.

S=fstat(fd,& buf) to get a files status information.

Fd= dup(fd) Allocate a new file descriptor for an open file.

S=pipe(&fd[0]) Create a pipe

S=ioctl(fd, request,argp) perform special opearation on a file

S=access( name, a mode) Check a files accessibility

S=rename(old,new) give a file a new name

S=fcnt(fd,cmd,..) file locking and other operations.


Basic interfaces of windows and UNIX :-

Windows supports the low level clients so its become famous among the users. Windows has several functions to make easier the users such as

Data exchange: - windows have capacity to exchange the data. Data exchange includes copy the file from one application to another and several others process which enables the data exchange operations.

Low level client support: - windows makes easier to the low level of clients to make its easier for using the system. That is the main reason that windows become more popular among the clients.

Resources: - The resources explain about the windows resources such as Icon, cursor and dialog box. These things also make it easier to the clients and also the main reason that makes its more graphical user interface (GUI) to support the clients.

User Input: - The user input section explains the ways of input is captured and it is used. The user input includes such as getting input from the mouse, keyboard, also some information from other devices etc. Also, user gets some date by using common dialog box.

Windowing: - Windows supports messages and message queues and also can learn how to use them in your applications.

Windows supports the Multiple Document Interface that defines a user interface for applications that enable the clients to work more then one documents as the same time

Windows supports window procedures. Each window has an associated window procedure that processes all messages sent to all windows of the class.

While discussing about the UNIX environment, the traditional UNIX user interface is a simple command-line shell which includes a windows with only the text terminal window with a fixed number of lines usually it contains 24 lines, and 80 columns is controlled by the shell program.

Also the shell prints a prompt when it is ready to receive commands.users can use the keyboard to input a command. Then the shell processes the command and executes it for the users. And also command prints its output, if any, to the same terminal windows. After the command is done, the shell prompts users again to enter next command. In general, the terminal window has no graphics, also there are specialized terminals having graphics and some UNIX programs can display images on them usually, the images is monochrome. Now as days, Modern PCs have all moved away from command-line interfaces and also created Graphical User Interface(GUI).