You are on page 1of 5

ASSIGNMENT-3

1. Compare: Producer-Consumer problem with Reader Writer problem Ans: Producer-Consumer Problem: The consumer producer problem (also known as the bounded-buffer problem) is a classical example of a multi-process synchronization problem. The problem describes two processes, the producer and the consumer, who share a common, fixed-size buffer used as a queue. The producer's job is to generate a piece of data, put it into the buffer and start again. At the same time, the consumer is consuming the data (i.e., removing it from the buffer) one piece at a time. The problem is to make sure that the producer won't try to add data into the buffer if it's full and that the consumer won't try to remove data from an empty buffer. Reader-Writer Problem: An object is shared among many threads, each belonging to one of two classes: Readers: read data, never modify it Writers: read data and modify it. Using a single lock on the data object is overly restrictive Want many readers reading the object at once Allow only one writer at any point Correctness criteria Each read or write of the shared data must happen within a critical section. Guarantee mutual exclusion for writers. Allow multiple readers to execute in the critical section at once. 2. Write a solution for writer priority of reader writer problem Ans: Semaphore Solution: Writers have Priority int readcount, writecount = 0; semaphore rsem, wsem = 1; // semaphore x,y,z = 1; // void reader(){ void writer(){ while(1){ while(1){ wait(z); wait(y); wait(rsem); writecount++; wait(x); if (writecount==1) readcount++; wait(rsem); if (readcount==1) signal(y); wait(wsem); wait(wsem); signal(x); doWriting(); signal(rsem); signal(wsem);

signal(z); doReading(); wait(x); readcount--; if (readcount==0) signal(wsem); signal(x); } }

wait(y); writecount--; if (writecount==0) signal(rsem); signal(y); } }

3. Explain drawbacks of Dekkers algorithm Ans: The drawbacks of Dekkers Algorithm are: It is limited to two processes and makes use of busy waiting instead of process suspension where use of busy waiting suggests that processes should spend a minimum of time inside the critical section. Modern operating systems provide mutual exclusion primitives that are more general and flexible than Dekker's algorithm. Many modern CPUs execute their instructions in an out-of-order fashion. This algorithm won't work on SMP machines equipped with these CPUs without the use of memory barriers. In many languages, it is legal for a compiler to detect that the flag variables flag[0] and flag[1] are never accessed in the loop. It can then remove the writes to those variables from the loop, using a process called Loop-invariant code motion. It would also be possible for many compilers to detect that the turn variable is never modified by the inner loop, and perform a similar transformation, resulting in a potential infinite loop. If either of these transformations is performed, the algorithm will fail, regardless of architecture. 4. compare android OS with windows Ans: ANDROID OPERATING SYSTEM There are four officially released Versions of Android: 1. Froyo 2. Ginderbread 3. Honeycomb 4. Ice cream Sandwich 5. Jelly beans [announced recently ] PROS of Android OS: Open Source Linux based System Custom ROMs High reliability Integrated Java and Flash

Dedicated App library, i.e., Google Play Wireless app installation Good security [No antivirus needed]

Cons of Android OS: Still Under Development

WINDOWS OPERATING SYSTEM


Windows is a very old operating system since year 1985. Windows 1 was the first operating system by Microsoft, after then they released many updated version of Windows like: Windows 95 [year - 1995] Windows 98 [year - 1998] Windows 2000 [year - 2000] Windows XP [2001] Windows Vista [year - 2006] Windows 7 [year - 2009] Windows 8 [year - 2012] Pros of Windows: Large user base Billion of peoples are used to Windows, so there are many programs for various fields over internet. Better User Interface It takes less time for a newbie to learn windows functioning. Its an old operating system, so large amount of fixes for various bugs will be available easily over internet. Cons of Windows: Not open source [so you need to buy license] Less secured as compared to Linux , you need an external antivirus to secure windows From Windows 95 to windows 7, Microsoft fixed many bugs and improved a lot but still it is not as reliable as linux is. Both of the operating system is best for the mobile and pc users but there are some factors that can distinguish android from the windows. 1. Gadgets Windows does not have the wide range of the Google gadgets that android provide to its user, more specifically mobile users. 2. Pricing Android is expensive than the pure licensed window operating system by Microsoft because of the additional feature and compatibility with almost every hardware and software

application brand. 3. Largest Computing Android offers the large range of applications and smart phone application to its users. It provides specific installations and setups for the Google chromes that Microsoft windows doesnt.

Parameters

iOS 6.0 650,000+ yes limited no no yes yes no no requires iTunes yes Cydia yes drop-down pane no yes no paid apps Darwin limited via Camera Connection Kit

Android 4.1 600,000+ yes yes yes yes yes yes yes yes with Google Now yes many outlets yes drop-down pane yes yes yes Linux yes

Window s Phone 8 100,000 + yes limited expanda ble Live Tiles yes yes

Window s Phone 7.8 100,000 + yes limited expanda ble Live Tiles yes yes

Apps Multitasking Widgets Expandable storage Multi-core processors High-res displays File manager Drag and drop file management Intelligent voice assistant Sideloading apps Centralized notifications Flash support Native screenshots Offline maps Core USB Host

yes yes no no no no requires Zune requires Zune no no no ? no no no no

? no no yes only Lumias Window Window s NT s CE 7 ? ?

5. Give the solution for reader writer problem with the help of monitor and message passing.

6. compare: semaphore, msg passing & monitor SEMAPHORES MONITORS Processes need to Processes need to share Memory share Memory It is a shared variable It is a programming that can be accessed language construct anywhere in the that has protected program. data that can be accessed only by No connection process inside the between the monitor. semaphore and data being controlled. The procedures in the monitor are in Inconvenient to use. direct contact with the data. MESSAGE PASSING Processes need not share Memory. It consists of data encapsulated into messages that are transferred between the sender and intended recipient. The sender and receiver have access to the message.

You might also like