Friday, January 8, 2010

Prelim Examination

Name: Pauline Vernadeth M. Magno Date: January 9,2010


I. Concept Questions
1. Name the five key concepts about an operating system that you thinks a user needs to know and understand.

Answer: For me the five key concept of Operating System that a user needs to know and understand are the following.
I. The major components of operating system, which are: Memory manager, Device Manager, File Manager, Processor Manager, and User command Interface.
II. How operating system handle the resource allocation and access the protection of the hardware.
III. How operating system allocates jobs in memory blocks.
IV. The importance of operating system.
V. How operating system involves in program execution.

2. List the tangible(physical) resources of the computer system and explain how it works.
a. Tower or Desktop The "box" or case that holds the parts that make up a computer: CPU, hard disk drive, floppy drive, memory chips, power supply, interface cards, etc.
b. Monitor An output display device (looks similar to a TV) in a computer system. You see information on the monitor's screen.
c.Speakers Output device that produces sound and music when connected to the computer. Speakers come in different shapes and may even be in the monitor's case.
d.Keyboard Input device - choose letters, symbols, and actions by pressing keys
3. Explain the following:
a. internal fragmentation. How does it occur?
b. External Fragmentation. How does it occur?
c. Compaction. Why it is needed?

Answers:
a. Internal fragmentation is the unused space, it occurs when storage is allocated without ever intending to use it. This space is wasted. While this seems foolish, it is often accepted in return for increased efficiency or simplicity. The term "internal" refers to the fact that the unusable storage is inside the allocated region but is not being used. source: http://en.wikipedia.org/wiki/Fragmentation_(computer)
b. External fragmentation is the phenomenon in which free storage becomes divided into many small pieces over time. It is a weakness of certain storage allocation algorithms, occurring when an application allocates and deallocates ("frees") regions of storage of varying sizes, and the allocation algorithm responds by leaving the allocated and deallocated regions interspersed. The result is that although free storage is available, it is effectively unusable because it is divided into pieces that are too small to satisfy the demands of the application. The term "external" refers to the fact that the unusable storage is outside the allocated regions. Source: http://en.wikipedia.org/wiki/Fragmentation_(computer)
c. Compaction attacks the problem of fragmentation by moving all the allocated blocks to one end of memory, thus combining all the holes. Aside from the obvious cost of all that copying, there is an important limitation to compaction: Any pointers to a block need to be updated when the block is moved. Unless it is possible to find all such pointers, compaction is not possible. Pointers can stored in the allocated blocks themselves as well as other places in the client of the memory manager. In some situations, pointers can point not only to the start of blocks but also into their bodies. For example, if a block contains executable code, a branch instruction might be a pointer to another location in the same block. Compaction is performed in three phases. First, the new location of each block is calculated to determine the distance the block will be moved. Then each pointer is updated by adding to it the amount that the block it is pointing (in)to will be moved. Finally, the data is actually moved. There are various clever tricks possible to combine these operations. source: http://www1bpt.bridgeport.edu/sed/projects/cs503/Spring_2001/kode/os/memory.htm#compaction

4.Cache memory how it works?
Ans: A cache (pronounced /kæʃ/, kash) is a collection of data duplicating original values stored elsewhere or computed earlier, where the original data is expensive to fetch (owing to longer access time) or to compute, compared to the cost of reading the cache. In other words, a cache operates as a temporary storage area where frequently accessed data can be stored for rapid access. Once the data is stored in the cache, it can be used in the future by accessing the cached
copy rather than re-fetching or recomputing the original data. source: http://en.wikipedia.org/wiki/Cache

5.Which is the fastest cache's L1, L2, or L3? Why?
Ans: The fastest cache is the L1-cache because the L1 cache typically ranges in size from 8KB to 64KB and uses the high-speed SRAM (static RAM) instead of the slower and cheaper DRAM (dynamic RAM) used for main memory. source: http://www.experts123.com/q/what-is-l1-cache-l2-and-l3-what-do-these-do.html


II. Memory Utilization Problem

1. Given the following information:

Table 1A

Job Number

Memory Requested

 J1

700KB

J2

500KB

J3

740KB

J4

850KB

J5

610KB


Memory Block

Size

1132

700KB

1003

720KB

1114

800KB

2310

750KB

1755

610KB

a.       a.Use the best-fit algorithm to allocate the memory blocks to the five arriving jobs.

b.      b.Use the first-fit algorithm to allocate the memory blocks to the five arriving jobs.

c.       c.Use the next-fit algorithm to allocate the memory blocks to the five arriving jobs.

d.      d.Use the worst-fit algorithm to allocate the memory blocks to the five arriving jobs.

AA       answer: 

a.       Best-fit  algorithm

Job Number

Memory Requested

 J1

700KB

J2

500KB

J3

740KB

*J4

850KB

 J5

610KB

(*IDLE)

                

Memory List


Memory Location

Memory Size

Job Number

Job Size

Status

Internal Fragmentation

1132

700KB

J1

700KB

BUSY

0

1003

720KB

J2

500KB

BUSY

120KB

1114

800KB

 

 

 

 

2310

750KB

J3

740KB

BUSY

10KB

1755

610KB

J5

610KB

BUSY

0

     b.First-Fit Algorithm

Job Number

Memory Requested

 J1

700KB

J2

500KB

J3

740KB

*J4

850KB

J5

610KB

Memory List

Memory Location

Memory Size

Job Number

Job Size

Status

Internal Fragmentation

1132

700KB

J1

700KB

BUSY

0

1003

720KB

J2

500KB

BUSY

120KB

1114

800KB

J3

740KB

BUSY

60KB

2310

750KB

J5

610KB

BUSY

140KB

1755

610KB

 

 

 

 


c.     Next-fit algorithm

Job Number

Memory Requested

 J1

700KB

J2

500KB

J3

740KB

*J4

850KB

J5

610KB

 (* IDLE)

Memory List

Memory Location

Memory Size

Job Number

Job Size

Status

Internal Fragmentation

1132

700KB

J2

500KB

BUSY

200KB

1003

720KB

J1

700KB

BUSY

20KB

1114

800KB

J5

610KB

BUSY

190KB

2310

750KB

J3

740KB

BUSY

10KB

1755

610KB

 

 

 

 

      d.Worst- fit algorithm

Job Number

Memory Requested

 J1

700KB

J2

500KB

*J3

740KB

*J4

850KB

J5

610KB

a.        (* IDLE)

 

 

Memory Block

Memory Location

Memory Size

Job Number

Job Size

Status

Internal Fragmentation

1132

700KB

 

 

 

 

1003

720KB

J5

610KB

BUSY

110KB

1114

800KB

J1

700KB

BUSY

100KB

2310

750KB

J2

500KB

BUSY

250KB

1755

610KB

 

 

 

 

2.  2.Given the following information:

    Table 2A 

Job Number

Memory Requested

J1

30KB

J2

50KB

J3

30KB

J4

25KB

J5

610KB

Table 2B

ORIGINAL

STATE OF

MAIN

MEMORY

 

 

100KB(P1)

25KB(P2)

25KB(P3)

 

50KB(P4)

 

30KB(P5)

                    

                                

a.       

a.       a.Create a memory layout for the fixed partition

               After job entry based on the given information

              (Table 2A and Table 2B)

b.      b.Before Job 6(30KB) and Job 7(45KB) arrives,

              There are three jobs done ready for processing

              which J2, J3, J4. Create an initial memory layout

              for dynamic partition based on the given information

              (Table 2A).

 

Ans: 

a.       a.Fixed partition. J5 is idle.   

AFTER

JOB

ENTRY

 30KB(J1)

 

 

 

 

25KB(J4)

50KB(J2)

 

30KB(J3)


                         

a.      








b.Dynamic Partition

       

   

Before

New  Job

Entry

 3OKB(J1)

 

 

 

25KB FREE

50KB FREE

 

 

30KB FREE

 

After

New  Job

Entry

 3OKB(J1)

 

 

 

25KB FREE

45KB(J7)

 

 

30KB(J6)

 


I. Concept Questions
1. Name the five key concepts about an operating system that you thinks a user needs to know and understand.

Answer: For me the five key concept of Operating System that a user needs to know and understand are the following.
I. How operating system works with the computer hardware.
II. How operating system handle the resource allocation and access the protection of the hardware.
III. How operating system allocates jobs in memory blocks.
IV. The importance of operating system.

Friday, December 4, 2009

VIRTUAL MEMORY

Virtual memory is a computer system technique which gives an application program the impression that it has contiguous working memory (an address space), while in fact it may be physically fragmented and may even overflow on to disk storage.

Developed for multitasking kernels, virtual memory provides two primary functions:
Each process has its own address space, thereby not required to be relocated nor required to use relative addressing mode.
Each process sees one contiguous block of free memory upon launch. Fragmentation is hidden.

All implementations (excluding emulators) require hardware support. This is typically in the form of a Memory Management Unit built into the CPU.

Systems that use this technique make programming of large applications easier and use real physical memory (e.g. RAM) more efficiently than those without virtual memory. Virtual memory differs significantly from memory virtualization in that virtual memory allows resources to be virtualized as memory for a specific system, as opposed to a large pool of memory being virtualized as smaller pools for many different systems.

Note that "virtual memory" is more than just "using disk space to extend physical memory size" - that is merely the extension of the memory hierarchy to include hard disk drives. Extending memory to disk is a normal consequence of using virtual memory techniques, but could be done by other means such as overlays or swapping programs and their data completely out to disk while they are inactive. The definition of "virtual memory" is based on redefining the address space with a contiguous virtual memory addresses to "trick" programs into thinking they are using large blocks of contiguous addresses.

Modern general-purpose computer operating systems generally use virtual memory techniques for ordinary applications, such as word processors, spreadsheets, multimedia players, accounting, etc., except where the required hardware support (a memory management unit) is unavailable. Older operating systems, such as DOS of the 1980s, or those for the mainframes of the 1960s, generally had no virtual memory functionality - notable exceptions being the Atlas, B5000 and Apple Computer's Lisa.

Embedded systems and other special-purpose computer systems which require very fast and/or very consistent response times may opt not to use virtual memory due to decreased determinism. This is based on the idea that unpredictable processor exceptions produce unwanted jitter on CPU operated I/O, which the smaller embedded processors often perform directly to keep cost and power consumption low. And the associated simple application has little use for multitasking features.



source: http://en.wikipedia.org/wiki/Virtual_memory

Windows Shell Script Demo Exercise

@ECHO
TITLE "KnockKnock.bat - The knockKnock joke game!"
COLOR OE
CLS
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
SET /p reply="KnockKnock! c:>"
CLS
IF NOT %reply%"Who is there?"
(ECHO "SORRY, but you are not playing the game right!" GOTO.EOF)
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
SET /p reoly="ORANGE c:>"
IF NOT %reply%"ORANGE WHO?"
(ECHO "SORRY, but you are not playing the game right!" GOTO.EOF)
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO "ORANGE you glad you've written your first WINDOWS shell Script?"
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.
ECHO.