Tuesday, January 15, 2008

Assingment 4

1. The major difference between deadlock, starvation and race is that in deadlock, the problem occurs when the jobs are processed.

Race conditions
: Threads can try to update the same data structure at the same time.
The result can be partly what one thread wrote and partly what the other thread wrote.


Deadlock
: To avoid updating the same data structure at the same time, threads lock a
data structure until they have finished making their modifications to it.


Starvation
: In its effects, starvation is similar to deadlock in that some threads do not
make progress. But the causes of starvation are different from those of deadlock: The
threads could, in theory, execute, but they just don’t get time on a processor, perhaps
because they don’t have a high enough priority.

2. Example of Deadlock:
When two trains approach each other at a crossing, both shall come to a full stop and neither shall start up again until the other has gone.
Example of Starvation:
When one person borrowed a pen from his classmate and hisclassmate get his pen back.
Example of Race:
When two guys have the same girlfriend.
3. Four necessary condition needed for the deadlock from exercise #2:
if the product is only one.if the two person needed that one product urgently.if there's other alternative products available.if the two person are brand concious and the product happen to be what they like.
4. Design an algorithm for using it so that both deadlock and starvation are not possible.
public boolean tryAcquire( int n0, int n1, ... )
{
if ( for all i: ni ≤ availi )
{ // successful acquisition availi -= ni for all i; returntrue; // indicate success } else return false; // indicate failure}init) Semaphore s = new Semaphore(1,1);Thread A Thread B-------- --------s.acquire(1,0); s.acquire(0,1);s.acquire(0,1); s.acquire(1,0);Thread B--------while(true) {s.acquire(0,1);if ( s.tryAcquire(1,0) ) // if second acquisition succeedsbreak; // leave the loopelse {s.release(0,1); // release what is heldsleep( SOME_AMOUNT); // pause a bit before trying again}}run action s.value--- ------ -------(1,1)A s.acquire(1,0) (0,1)B s.acquire(0,1) (0,0)A s.acquire(0,1)A blocks on secondB s.tryAcquire(1,0) => falseB s.release(0,1) (0,1)A s.acquire(0,1) (0,0) A succeeds on second
5. Deadlock will not happen because there are two traffic lights that control the traffic.
a.But when some motorist don't follow the traffic lights, deadlock can occur because there's only one bridge to drive through.
b. Deadlock can be detected when there will be a huge bumper to bumper to the traffic and there will be accident that will happen.
c. The solution to prevent deadlock is that, the traffic lights should be accurate and motorist should follow it. In order to have a nice driving through the bridge.
6. Based on figure 5.17 answer the following question.
a. is this system deadlock?-this is an deadlock because P2 still requesting or waitng for R1 that has already been allocated.

Thursday, December 13, 2007

Assignment 3

1.Expain the following:
a.Multiprogramming.Why is it used?
Multiprogramming is a feature of an OS which allows running multiple programs simutaneously on 1 CPU. So, say, you may be typing in word, listning to music while in background IE is downloading some file & anti-virus program is scanning. These all happen simultaneously to you. Actually programs dont run simultaneously, but OS divides time for each program acccording to priorities. When the chance of that program comes it runs, after the stipulated time is over, next program runs & so on. Since this process is so fast that it appears programs are running simultaneously.
b. Internal fragmentation.How this it occur?
Internal fragmentation 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.
c.External fragmentation.How does it occurs?
External fragmentation also occurs in file systems as many files of different sizes are created, change size, and are deleted. The effect is even worse if a file which is divided into many small pieces is deleted, because this leaves similarly small regions of free space.
d.Compaction.Why is it needed?
Compaction is very needed because it is the process of collecting fragments of available memory space into contiguous in block by moving programs and data in acomputer's memory disks, or known as garbage collection.
e.Relocation.How often should it be performed?
It depend on the process of address refferences in program
.
2. Describe the Major Disadvantages for each of the four memory allocation schemes presented in the chapter.
The disadvantage of this memory allocation its an overhead process, so that while compaction is being done everything else must wait.
3.Describe the Major Advantages for each of the memory alloatiuon schemes presented in the chapter.
They could be divided into segments of variable sizes of equal size. Each page, or segment, could be stored wherever there was an empty block best enough to hold it.

page 104Exercises:
4.What is the cause of thrashing?
Thrashing is caused by under allocation of the minimum number of pages required by a process, forcing it to continuously page fault.B:How does the operating system detect thrashing?The system can detect thrashing by evaluating the level of CPU utilization as compared to the level of multiprogramming.C:Once thrashing is detcted, what can the operating system do to iliminate it?It can be eliminated by reducing the level of multiprogramming.
5.What purpose does the referenced bit serve in a demand paging system?
The main idea here was to have the operation system maintain its own array of reference bits (that's the easy part) the tricky part is that the OS must somehow learn about the accesses made to pages. The best way to do this was to mark pages as invalid so that an access to the page causes a trap to the OS, which can do the bookkeeping (of course, the OS must keep extra information around to be able to tell which page table entries are truly invalid). The clock algorithm could reset the invalid bit when it checked an accessed page. The extra costs are additional traps to the OS just for normal references (depend on how fast your clock moves) and extra complexity in the OS.

Thursday, November 29, 2007

assingment 2

virtual memory

The purpose of virtual memory is to enlarge the address space, the set of addresses a program can utilize. For example, virtual memory might contain twice as many addresses as main memory. A program using all of virtual memory, therefore, would not be able to fit in main memory all at once. Nevertheless, the computer could execute such a program by copying into main memory those portions of the program needed at any given point during execution.
1.UNIX and Windows virtual memory
Our Virtual Servers uses Unix BSDI operating systems for the majority of its servers because of the superior performance, flexibility and cost efficiency that Unix BSDI offers. The following is a comparison of the BSDI system to the Windows NT system.
Performance
With Unix and Windows NT running on standard PC's, Unix ran 27% faster than Windows NT when reading static HTML content, and with API generated content, Unix is between 47% and 197% faster. For CGI contents, Unix is 77% faster than Windows NT.
Internet Services
Unix has included things such as SMTP (Email), NNTP (News), Telnet, and DNS. All of these protocols and services were somehow forgotten by Windows NT. They can be covered up with third party products and Microsoft's own programs. However, none of these programs and products can compare to Unix in terms of flexibility and power.vv
Price Comparison
With the Unix server's cost at approximately one fourth that of the Windows NT, it allows us to provide you with a more cost effective and powerful way to be on the Internet.

Thursday, November 22, 2007



















2. Two resons why a regional bank use 6 server computers than one supercomputers:
  • it can perform fastier than one supercomputer.
  • it easy to use.

Wednesday, November 21, 2007

Assignment 1

1.About Operating system

The most important program that runs on a computer. Every general-purpose computer must have an operating system to run other programs. Operating systems perform basic tasks, such as recognizing input from the keyboard, sending output to the display screen, keeping track of files and directories on the disk, and controlling peripheral devices such as disk drives and printers.
For large systems, the operating system has even greater responsibilities and powers. It is like a traffic cop -- it makes sure that different programs and
users running at the same time do not interfere with each other. The operating system is also responsible for security, ensuring that unauthorized users do not access the system.
Operating systems can be classified as follows:
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.
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.


Evaluation of the article:
-operating system is the main without this the program is useless cause it will not run.