Sunteți pe pagina 1din 6

What is an os?

1

Programs with special privileges on the hardware that let them run and manage other programs.

First program to run when a computer is turned on.

All subsequent programs are started by the OS.

Started in 1950s.

First they were made to manage the manual task of loading programs by hand.

Batch programming began.

- When one task ended, next was in line automatically. There was no need for humans to run after bring the next code.

When systems were less costly, software sharing began.

So hardware interfacing became a problem. This became a tough task for programmers.

So OS began to act as an interface between software and hardware peripherals device drivers.

First supercomputer ATLAS university of Manchester -1962

it provided scheduling which allowed multitasking

now each program was allotted its own block of memory

- But memory was not allocated sequentially, it was usually scattered all over the block. this becomes very confusing for programmers

Here virtual memory came to rescue. A new level of abstraction. Address always APPEARS to start from 0. Virtual to physical memory mapping is managed by OS.

Memory protection is also provided.

When computers became cheaper, OS had to handle multiple users. Time sharing was developed

First time sharing OS multics -1969 multiplexed information and computing service

Used a lot of memory

So Ken Thompson and Dennis Ritchie developed UNIX.

separated OS into 2 parts

- First core functionality memory management, multitasking, dealing with I/O kernel

- Second programs and applications.

2

By 1990s MS DOS came to being just 160kB

lacked multitasking and memory protection

Crashes more frequent.

Why do we need it?

A human running around putting programs into readers was a very slow process.

So we needed computers to compute themselves.

Life without OS

- Earliest computers didn’t have OS.

- They were huge machines

- They completed one task at a time. For this, they did not need any OS

- They required users to physically connect and disconnect wires from a plug board to retrieve computations.

How can computer do calculation without OS?

The users write code that tells computers what exactly to do.

Difference b/w different versions of windows

1. MS DOS very simple. Command based

2. Windows 1.0 -2.0 85-92 allowed point and click to access

Desktop icons, keyboard shortcuts, graphics

3. Windows 3.0 3.1 90-94 better icons, performance, advanced graphics 16

colors

Included program manager, file manager, print manager, games

4. Windows 95 a number of internal improvements

Supports 32 bit applications

Longer file names

Plug and play feature ability to automatically detect and configure installed hardware

5. Windows 98 provides active desktop feature

Integrates web browser internet explorer

6. Windows 2000 - os for business desktop and laptop systems

7. Windows XP redesigned look and feel

Connect to wireless networks

Utilizes 802.11x wireless security standard

8. Windows Vista advancement in reliability, security, performance

3

Detect hardware problems

Security features, faster start-up time, low power consumption

9. Windows 7 improved performance and start up time, improved security

10. Windows 8 completely redesigned os

Built for touch screen use in mind

Instant on capabilities.

11. Windows 10 fast start up and resume

Built in security

Return of start menu

How is windows different from Linux

1. Linux is open source. Windows is commercial

2. Linux has command line.

3. Linux has centralized application installation. Windows is non-centralized.

4. Linux is flexible. Windows is rigid.

How is UNIX different from Linux

1. UNIX source code is not easily available. Linux source code open source.

2. UNIX is not portable, whereas Linux is.

3. Linux can be installed on home based PCs. UNIX installation is comparatively tricky.

4. Unix is used in server systems, high end computers.

Semaphore

Semaphore is a variable used to solve critical section problem

- Achieves process synchronization

- Maintains a count between 0 and a specified max value.

- The count is decremented each time a thread completes a wait for the semaphore object

- Count is incremented when the thread releases semaphore.

- Useful in controlling a shared resource that can support a limited number of users.

- Semaphores are used for signaling between threads.

Mutex

Mutex provides mutual exclusion.

4

- Usually used for concurrency protection of resources

- When a mutex is taken, the thread owns the mutex and the same thread must later release the mutex back to release the resource.

** semaphore vs mutex

- Consider the producer consumer problem. Suppose buffer is of size 4096 B.

- A producer thread collects the data and writes it to the buffer. A consumer thread processes the collected data from the buffer.

- Objective is, both the threads should not run at the same time.

- A mutex provides mutual exclusion; either producer or consumer can have the key (mutex) and proceed with their work.

- As long as the buffer is filled by producer, the consumer needs to wait, and vice versa.

- At any point of time, only one thread can work with the entire buffer. The concept can be generalized using semaphore.

- A semaphore is a generalized mutex.

- In lieu of single buffer, we can split the 4 KB buffer into four 1 KB buffers (identical resources).

- A semaphore can be associated with these four buffers. The consumer and producer can work on different buffers at the same time.

Real life producer/consumer

- Web service receives http requests for data, places request on a queue. Worker thread pulls the work item from queue and performs the work.

- Printing of documents

Process

An instance of program in execution.

E.g. web browser is a process

Has 3 states running, ready, waiting

Thread

A single sequence stream within a process

Lightweight processes

Improve parallelism

E.g. multiple tabs are different threads. Ms word uses one thread to edit document other to perform spell check etc.

5

Threads have their own PC, register and stack

Threads share code section, data section and os resources

Why thread

Threads can share data :D no need of IPC

Can take advantage of multi processors

Only need a stack and registers cheap to create

No need of new address space, code

Faster context switching

No protection between threads.

** Any program which does more than one task at a time should use thread

** Any sequential task that cannot be made parallel does not need threads.

Deadlock

A situation where 2 or more processes wait for each other to finish but none of them ever finishes.

When 2 processes hold some resource and wait for resource held by other

1. 4 conditions mutual exclusion resource cannot be shared.

2. Hold and wait process holding one resource and waiting for some other resource

3. No preemption

4. Circular wait

Deadlock prevention vs deadlock avoidance

- Prevention- imposes restrictions on programs to prevent the possibility of deadlock

- Avoidance check resource requests and availability at run time to avoid deadlock

Prevent - stop avert | avoid dodge duck get around circumvent

Virtual Memory

- Creates an illusion that each user has contiguous address space

- Uses disk space to extend the RAM

- Process does not care whether memory is from RAM or disk

Thrashing

6

When system spends more time processing page faults than executing transactions

Belady anomaly

When increasing number of page frames result in increase in number of page faults