System Programing Solve 1

18
HOMEWORK NO.1 SYSTEM SOFTWARE SUBMITTED TO: SUBMITTED BY: Mandeep Kaur Surendra MCA 4 th SEM D3804A15 10806601 Declaration: I declare that this assignment is my individual work. I have not copied from any other student’s work or from any other source except where due

Transcript of System Programing Solve 1

Page 1: System Programing Solve 1

HOMEWORK NO.1

SYSTEM SOFTWARE

SUBMITTED TO: SUBMITTED BY:

Mandeep Kaur Surendra

MCA 4th SEM

D3804A15

10806601

Declaration:

I declare that this assignment is my individual work. I have not copied from any other student’s work or from any other source except where due acknowledgment is made explicitly in the text, nor has any part been written for me by another person.

Student’s Signature: ___Surendra__________

Page 2: System Programing Solve 1

Q 1. System software is different from operating system. How?

Answer:

System software is computer software designed to operate the computer hardware and to provide and maintain a platform for running application software.

Systems software refers to the Operating System and all utility programs (like Compiler, Loader, Linker, and Debugger) that manage computer resources at a low level.

Systems software refers to the Operating System and all utility programs (like Compiler, Loader, Linker, and Debugger) that manage computer resources at a low level.

A term for a complicated set of programs that act together to allow a computer, and other programs, to function.

The software that controls the operations of a computer system. It is a group of programs rather than one program.

Operating system has the following conditions which satisfy the conditions of being a system:

Multi-user: Allows two or more users to run programs at the same time. Some operating systems permit hundreds or even thousands of concurrent users.

Multiprocessing: Supports running a program on more than one CPU.

Multitasking: Allows more than one program to run concurrently.

Page 3: System Programing Solve 1

Multithreading: Allows different parts of a single program to run concurrently.

Real time: Responds to input instantly. General-purpose operating systems, such as DOS and UNIX, are not real-time.

Operating systems provide a software platform on top of which other programs, called application programs, can run. The application programs must be written to run on top of a particular operating system. Your choice of operating system, therefore, determines to a great extent the applications you can run. For PCs, the most popular operating systems are DOS, OS/2, and Windows, but others are available, such as Linux.

As a user, you normally interact with the operating system through a set of commands. For example, the DOS operating system contains commands such as COPY and RENAME for copying files and changing the names of files, respectively. The commands are accepted and executed by a part of the operating system called the command processor or command line interpreter. Graphical user interfaces allow you to enter commands by pointing and clicking at objects that appear on the screen.

Q 2. Operating system rules the system give your comments? Give its architectural details?

Answer:

To put it in the simplest of words, an operating system is a computer program written to make the computer understandable to the User who does not know the assembly level language of the computer.

Rules of Operating System:

1.Management of the Processor

Page 4: System Programing Solve 1

2.Management of the R.A.M

3.Management of the Input/output

4.Management of the Execution of Application

5.Management of the Authorization

6. File Management

Simple view:

The computer architecture of a computing system defines its attributes as seen by the programs that are executed in that system, that is, the conceptual structure and functional behaviour of the machine hardware. Then, the computer architect defines the functions to be executed in the hardware and the protocol to be used by the software in order to exploit such functions. Note that the architecture has nothing to do with the organization of the data flow, the logical design, the physical design, and the performance of any particular implementation in the hardware.

An Operating System is the layer between the hardware and software, as in

 

Kernel

The kernel of an operating system is the part responsible for all other operations. When a computer boots up, it goes through some initialisation functions, such as checking memory. It then loads the kernel and switches control to it. The kernel then starts up all the processes needed to communicate with the user and the rest of the environment (e.g. the LAN)

The kernel is always loaded into memory, and kernel functions always run, handling processes, memory, files and devices.

Page 5: System Programing Solve 1

The traditional structure of a kernel is a layered system, such as UNIX. In this, all lay-ers are part of the kernel, and each layer can talk to only a few other layers. Applica-tion programs and utilities live above the kernel. The UNIX kernel looks like

Most of the Operating Systems being built now use instead a micro kernel, which minimises the size of the kernel. Many traditional services are made into user level services. Communication being services is often by an explicit message passing mechanism.

The major micro-kernel Operating System is Mach. Many others use the concepts of

Mach.

Page 6: System Programing Solve 1

Q 3. Assemblers, compilers, linker and loader are termed as programming systems? Give examples?

Answer:

Assemblers-assembler is used to translate assembly language statements into the target computer's machine code. The assembler performs a more or less isomorphic translation (a one-to-one mapping) from mnemonic statements into machine instructions and data. This is in contrast with high-level languages, in which a single statement generally results in many machine instructions.

There are two types of assemblers based on how many passes through the source are needed to produce the executable program.

Assemblers are generally simpler to write than compilers for high-level languages, and have been available since the 1950s. Modern assemblers, especially for RISC based architectures, such as MIPS, Sun SPARC, and HP PA-RISC, as well as x86(-64), optimize instruction scheduling to exploit the CPU pipeline efficiently.

Page 7: System Programing Solve 1

Compiler-A compiler is a computer program (or set of programs) that transforms source code written in a computer language (the source language) into another computer language (the target language, often having a binary form known as object code). The most common reason for wanting to transform source code is to create an executable program. E.g. Are c, c++ vb, and c #complers.

Loader-A loader is a routine that loads an object program and prepars it for exeqution. There are various loading schemes: absolute, relocating, and direct linking. In general, the loader must load, relocate, and link the object program.

Example-if a user wished to employee a square root subroutine, he would have to right his main program so that it would transfer to the location assigned to the square root routine (sqrt).his program and subroutine would be assembled together. If a second user wished to use the same subroutine, he also would assemble it along with his own program, and the complete machine language translation would be loaded into memory.

Linker-linker is the part of an operating system (OS) that loads and links the shared libraries for an executable when it is executed. The specific operating system and executable format determine how the dynamic linker functions and how it is implemented. Linking is often referred to as a process that is performed at compile time of the executable while a dynamic linker is in actuality a special loader that loads external shared libraries into a running process and then binds those shared libraries dynamically to the running process.

Q 4. Give application areas of various types of operating system with examples?

Answer:

An operating system (OS) is an interface between hardware and user, which is responsible for the management and coordination of activities and the sharing of the resources of a computer, that acts as a host for computing applications run on the machine. One of the purposes of an operating system is to handle the resource allocation and access protection of the hardware.

The different types of operating systems are as under:

Page 8: System Programing Solve 1

• Real-time operating system (RTOS) - Real-time operating systems are used to control machinery, scientific instruments and industrial systems. An RTOS typically has very little user-interface capability, and no end-user utilities, since the system will be a "sealed box" when delivered for use. A very important part of an RTOS is managing the resources of the computer so that a particular operation executes in precisely the same amount of time, every time it occurs. In a complex machine, having a part move more quickly just because system resources are available may be just as catastrophic as having it not move at all because the system is busy.

• Single-user, single task - As the name implies, this operating system is designed to manage the computer so that one user can effectively do one thing at a time. The Palm OS for Palm handheld computers is a good example of a modern single-user, single-task operating system.

• Single-user, multi-tasking - This is the type of operating system most people use on their desktop and laptop computers today. Microsoft's Windows and Apple's Mac OS platforms are both examples of operating systems that will let a single user have several programs in operation at the same time. For example, it's entirely possible for a Windows user to be writing a note in a word processor while downloading a file from the Internet while printing the text of an e-mail message.

• Multi-user - A multi-user operating system allows many different users to take advantage of the computer's resources simultaneously. The operating system must make sure that the requirements of the various users are balanced, and that each of the programs they are using has sufficient and separate resources so that a problem with one user doesn't affect the entire community of users. Unix, VMS and mainframe operating systems, such as MVS, are examples of multi-user operating systems.

Page 9: System Programing Solve 1

Part B

Q 1. Operating system can be divided into how many parts give details of each?

Answer:

The operating system's tasks, in the most general sense, fall into six categories:

•Processor management:

The basic unit of software that the operating system deals with in scheduling the work done by the processor is either a process or a thread, depending on the operating system.

It's tempting to think of a process as an application, but that gives an incomplete picture of how processes relate to the operating system and hardware. The application you see (word processor, spreadsheet or game) is, indeed, a process, but that application may cause several other processes to begin, for tasks like communications with other devices or other computers

•Memory storage and management:

When an operating system manages the computer's memory, there are two broad tasks to be accomplished:

Each process must have enough memory in which to execute, and it can neither run into the memory space of another process nor be run into by another process.

The different types of memory in the system must be used properly so that each process can run most effectively.

The first task requires the operating system to set up memory boundaries for types of software and for individual applications.

As an example, let's look at an imaginary small system with 1 megabyte (1,000 kilobytes) of RAM. During the boot process, the operating system of our imaginary

Page 10: System Programing Solve 1

computer is designed to go to the top of available memory and then "back up" far enough to meet the needs of the operating system itself. Let's say that the operating system needs 300 kilobytes to run. Now, the operating system goes to the bottom of the pool of RAM and starts building up with the various driver software required to control the hardware subsystems of the computer. In our imaginary computer, the drivers take up 200 kilobytes. So after getting the operating system completely loaded, there are 500 kilobytes remaining for application processes.

•Device management:

The path between the operating system and virtually all hardware not on the computer's motherboard goes through a special program called a driver. Much of a driver's function is to be the translator between the electrical signals of the hardware subsystems and the high-level programming languages of the operating system and application programs. Drivers take data that the operating system has defined as a file and translate them into streams of bits placed in specific locations on storage devices, or a series of laser pulses in a printer.

•Application interface:

Just as drivers provide a way for applications to make use of hardware subsystems without having to know every detail of the hardware's operation, application program interfaces (APIs) let application programmers use functions of the computer and operating system without having to directly keep track of all the details in the CPU's operation. Let's look at the example of creating a hard disk file for holding data to see why this can be important.

•User interface:

In the end user interface provides the platform to the user to interact with the computer or any type of machine. Just as the API provides a consistent way for applications to use the resources of the computer system, a user interface (UI) brings structure to the interaction between a user and the computer. In the last decade, almost all development in user interfaces has been in the area of the graphical user interface (GUI), with two models, Apple's Macintosh and Microsoft's Windows, receiving most of the attention and gaining most of the market share. The popular open-source Linux operating system also supports a graphical user interface.

Page 11: System Programing Solve 1

Q2. Machine language differs from assembly language give examples? Write a program to display your name using any of machine languages?

Answer:

Machine language-Machine code or machine language is a system of instructions and data executed directly by a computer's central processing unit. Machine code may be regarded as a primitive (and cumbersome) programming language or as the lowest-level representation of a compiled and/or assembled computer program.. Machine code is sometimes called native code when referring to platform-dependent parts of language features or libraries. Machine code should not be confused with so called "byte code", which is executed by an interpreter.

Example-

The MIPS architecture provides a specific example for a machine code whose instructions are always 32 bits long. The general type of instruction is given by the op (operation) field, the highest 6 bits. J-type (jump) and I-type (immediate) instructions are fully specified by op. R-type (register) instructions include an additional field funct to determine the exact operation. The fields used in these types are:

6 5 5 5 5 6 bits

[ op | rs | rt | rd |shamt| funct] R-type

[ op | rs | rt | address/immediate] I-type

[ op | target address ] J-type

rs, rt, and rd indicate register operands; shamt gives a shift amount; and the address or immediate fields contain an operand directly.

For example adding the registers 1 and 2 and placing the result in register 6 is encoded:

[ op | rs | rt | rd |shamt| funct]

Page 12: System Programing Solve 1

0 1 2 6 0 32 decimal

000000 00001 00010 00110 00000 100000 binary

Load a value into register 8, taken from the memory cell 68 cells after the location listed in register 3:

[ op | rs | rt | address/immediate]

35 3 8 68 decimal

100011 00011 01000 00000 00001 000100 binary

Jumping to the address 1024:

[ op | target address ]

2 1024 decimal

000010 00000 00000 00000 10000 000000 binary

Assembly language-A program written in assembly language consists of a series of instructions--mnemonics that correspond to a stream of executable instructions, when translated by an assembler, that can be loaded into memory and executed.

For example- an x86/IA-32 processor can execute the following binary instruction ('MOV') as expressed in machine language (see x86 assembly language):

Hexadecimal: B0 61 (Binary: 10110000 01100001)

The equivalent assembly language representation is easier to remember (example in Intel syntax, more mnemonic):

MOV AL, 61h

Page 13: System Programing Solve 1

This instruction means:

Move (really a copy) the hexadecimal value '61' into the processor register known as "AL". (The h-suffix means hexadecimal or = 97 in decimal)

Q3. Explain algorithm of pass 1 of two-pass assembler.

Answer: First pass:

1. Scans the code

2. Validates the tokens

3. Creates a symbol table First Pass: Constructing the Symbol Table

1. Find the .ORIG statement, which tells us the address of the first instruction.

•Initialize location counter (LC), which keeps track of the current instruction.2. for each non-empty line in the program:a) If line contains a label, add label and LC to symbol table.

b) Increment LC.

NOTE: If statement is .BLKW or .STRINGZ, increment LC by the number of words allocated.

3.Stop when .END statement is reached.

Q4. Explain algorithm of pass 2 of two-pass assembler.

Answer:

Second Pass:

1. Solves forward references

Page 14: System Programing Solve 1

2. Converts the code to the machine code

Second Pass: Generating Machine Language

•For each executable assembly language statement, generate the corresponding machine language instruction

•If operand is a label, look up the address from the symbol table.