Tuesday, January 15, 2008

Exercises

1.A deadlock is a situation wherein two or more competing actions are waiting for the other to finish, and thus neither ever does.

A Starvation is similar in effect to deadlock. Two or more programs become deadlocked together, when each of them wait for a resource occupied by another program in the same set. On the other hand, one or more programs are in starvation, when each of them is waiting for resources that are occupied by programs, that may or may not be in the same set that are starving. Moreover, in a deadlock, no program in the set changes its state.

A race is a synchronozation problem between two processes vying for the same resources.

2. Real-life example of deadlock is the traffic.
Real-life example of starvation is in the staircase, when two people meet at the opposing side. The staircase can be accomodated by one person.
Real-life example of Race is when two people arrived at the same time on the same door.

3. Four Necessary Conditions for Deadlock:
The presence of deadlock in a systems is characterized by these four necessary conditions. The term necessary means that if there is deadlock then all four must be present.

a. Mutual exclusive resource access - A resource acquired is held exclusively, i.e., it is not shared by other processes.
b. No preemption - A process' resources cannot be taken away from it. Only the process can give up its resources.
c. Hold and Wait - A process has some resources and is blocked requesting more.
d. Circularity - This means that there is a circular chain of two or more processes in which the resources needed by one process are held by the next process.

4. Algorithm for prevention of deadlock and starvation:public boolean tryAcquire( int n0, int n1, ... ) { if ( for all i: ni ≤ availi ) { // successful acquisition availi -= ni for all i; return true; // 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.a. Deadlock can be occurred. When the bridge is destroyed.
b. When there are no traffic lights.
c. To prevent deadlock follow the traffic light.

6.a. This is not a deadlocked.b. There is no blocked processes.c. P2 can freely request on R1 and R2.d. P1 can freely request on R1 and R2.e. Both P1 and P2 have requested R2.1. P1 will wait after the request of P2.2. P2 will wait after the request of P1.

Thursday, December 13, 2007

Case Study: Memory Management in Linux

To highlight the concets presented in this chapter, we end with a more specific example of how memory managed in the Linux operating system. Although Linux memory management has many features in common with UNIX, it has some unique characteristics, and it is quite complex.
Virtual Memory in Linux managed using a three-level table hierarchy, which acoomodates both 64- and 32-bit architectures. For the example show in Figure 3.18, each virtual address is made up of four filds, which are used by the Memory Manager to locate the instruction or data requested:


Main Directory Middle Directory Page Table Directory Actual Page Offset
Figure 3.18 refers to the following virtual address:
Job: 1 Page Table: 3 Page: 2 Line:214


Each job has its own entry in the main directory, which has pointers to each job's middle director. A job's middle directory contains pointers to its corresponding page table directories. In turn, each page table directory has pointers to the actual pages, as shown in Figure 3.18. Finally, the page offset field is used to locate the instruction or data within the requested page (Line 214).



Consider the case where main memory consists of 64 page frames and Job 1 resists 15 page frames. The buddy algorithm first rounds up the request to a power of 2 ( in this case 2 to the 4, which is 16). The group of 64 page frames is divided into two page frames that can satisfy the request, so the job's pages are copied into the page frames as shown in Figure 3.19(a). When job 2 requests 8 page frames, the second page up to 16 page frames is divided in two and the lower half is given to Job 2, as show in Figure 3.19 (b).


When Job 2 releases its page frames they are combined with the upper 8 page frames form a group of 16 page frames, as shown in Figure 3.19(c).


The Page replacement algorithm used by the Linux is an expanded version of the clock algorithm presented in the page replacement policies section of this chapter. Instead of using a single reference bit, Linux uses an 8-bit byte to keep track of a page's activity, which is referred to as its age. Each time a page is referenced, this age variable is incremented. Behind the scenes, at specific intervals, the Memory Manager checks each of use age variables and decreases their value by one. The result of this interaction is it, if a page is not referenced frequently, then its age variable will drop to zero and will be a good candidate for replacement if a page swap is necessary. On the other hand, a page that is frequently used will have a large age value and will not be a good choice for replacement. Therefore, we can say that Linux uses a form of least frequently used (LRU) replacement policy.

Tuesday, November 27, 2007

OPERATING SYSTEMS VIRTUAL MEMORY

Virtual Memory campare into windows and unix

Unix vs. Windows NT Comparison
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.
EfficiencyUnix offers more performance at 1000MB than Windows NT offers at 2000MB. Unix is usually more proficient in the use of its memory, especially when dealing with network services. Because Unix requires less memory and processor time than Windows NT, a Unix based system has more memory and processor power for other computer functions.
PerformanceWith 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.
ReliabilityIndividuals and subsystems running on Windows NT crash far more frequently than a Unix system. Unix has been reliable for years due to its dependable software and technology.
Remote ManagementUnix was designed and implemented with remote management in mind. This enables system administrators to remotely perform management operations from another building or across the world. Windows NT is configured so that most of the administrative programs have to be run on the physical machine, without the ability to remotely control the machine.
Internet ServicesUnix 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.
Price ComparisonWith 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.

Wednesday, November 21, 2007

2.) Reasons why regional bank might decide to buy six server computers instead of one supercomputers

  • have backups for their important files while the other computers committed error.
  • have 3 or 4 computers running while 2 or 3 computers have their maintenance.

Microsoft: Don't sell PCs without operating systems

Microsoft has urged UK PC vendors not to give customers the opportunity to buy a PC without a pre-installed operating system.

Supplying base systems, or 'naked PCs', is a missed opportunity, according to Michala Alexander, Microsoft's head of anti-piracy.Writing in Microsoft's Partner Update magazine, which is distributed to computer dealers, Alexander estimated that 5 percent of computers sold in the UK in 2006 would not include an operating system.Alexander is keen to bring that number down, even though customers could want a base system because they want to install Linux, or because their firm already has a licensing agreement for an operating system such as Windows."We want to urge all system builders — indeed, all Partners — not to supply naked PCs. It is a risk to your customers and a risk to your business — with specifically 5 percent fewer opportunities to market software and services," wrote Alexander.Linux vendors and free software supporters, though, believe these base systems can play an important role in supporting the open source market. Some are concerned that Microsoft may be attempting to use its powerful position in the market to hamper competition.The European branch of the Free Software Foundation hopes that PC vendors will not be swayed by Microsoft."We would be happy to see any kind of hardware being shipped without an operating system, or pre-installed with free software. Furthermore, we would be happy to get in contact with any hardware vendor who wants to free his customers this way," said Joachim Jakobs, of the FSF Europe.Alexander's role is to combat the use of counterfeit and unlicensed versions of Microsoft's software. In February, Microsoft launched an initiative called Keep IT Real, in which "feet on the street" investigators would visit technology vendors suspected of installing counterfeit software on PCs before selling them.In the article, Alexander appeared to reveal that these investigators will also have a role in clamping down on the sale of base systems."Microsoft is recruiting two 'feet on the street' personnel whose role will be to provide proactive assistance during customer visits, and help you get the value proposition for pre-installed software and related services. Give us a call and let's get those feet walking," Alexander wrote.The FSF Europe is alarmed by the prospect that customers who request a base systems would risk a visit from Microsoft's investigators."It looks like a private sniffing service which is supposed to spy on these who do not want to pay the Microsoft tax anymore. It is an incredible piece of impudence which any politician, customer and journalist should recognise carefully," said Jakobs.When contacted by ZDNet UK, Alexander denied that operatives would be dispatched into the premises of customers who attempted to buy a PC without Windows."I can confirm that the... personnel are not participating in customer visits. This is an error in the copy and will be amended in future material on the subject," Alexander claimed.Alexander also insisted that Microsoft was simply trying to help its reseller partners by explaining how they could grow their businesses by selling its software and services. But she did reiterate that the software giant is concerned that the sale of base systems may be linked to the use of counterfeit software."There will be a concern if we see an increase in businesses selling PCs without Windows and piracy goes into the sky," said Alexander, who also rejected the suggestion that Microsoft was attempting to use its powerful position in the market to hamper rival operating systems.Both Red Hat and Novell argue that naked PCs can be an important part of the overall market."Microsoft is clearly concerned about the threat of Linux on the desktop and is trying to protect its base. Naked PCs provide customers with choice and lower the price of commodity PCs," said a Novell spokesman."Customers want to have choice and they don't want to be locked in by one vendor, such as Microsoft," said Red Hat's Dirk Kissinger. "We would like to see more hardware vendors give their customers the choice of pre-installed operation systems, be it Microsoft or Red Hat or other options, or raw hardware without an operating system."Several PC vendors contacted by ZDNet UK were reluctant to comment on the issues surrounding base systems. One, though, did say that they hadn't encountered any difficulties."We've had no pressure from Microsoft, yet," said a representative from Chillblast, a UK PC vendor that sells some computers without operating systems.

Source: http://news.zdnet.co.uk/software/