Free Essay

Assignment

In:

Submitted By deviljayne
Words 3058
Pages 13
1. Deadlock (“deadly embrace”) is a system-wide tangle of resource requests that begins when 2 or more jobs are put on hold.

• Each job is waiting for a vital resource to become available. • Needed resources are held by other jobs also waiting to run but can’t because they’re waiting for other unavailable resources. • The jobs come to a standstill. • The deadlock is complete if remainder of system comes to a standstill as well.

• The resources can be categorized into physical and logical resources. The physical resources are printer, disk drive, cpu, memory, scanner etc. The logical resources are files.

• Deadlock is more serious than indefinite postponement or starvation because it affects more than one job.

• Because resources are being tied up, the entire system (not just a few programs) is affected.

• Requires outside intervention (e.g., operators or users terminate a job) to resolved the deadlock.

2. Seven Cases of Deadlocks

Case 1 Deadlocks on file requests

Case 2 Deadlocks in databases

Case 3 Deadlocks in dedicated device allocation

Case 4 Deadlocks in multiple device allocation

Case 5 Deadlocks in spooling

Case 7 Deadlocks in disk sharing

Case 8 Deadlocks in a network

Case 1: Deadlocks on File Requests

| |If jobs can request and hold files for duration of their |
| |execution, deadlock can occur. |
| | |
| |Any other programs that require F1 or F2 are put on hold as long |
| |as this situation continues. |
| | |
| |Deadlock remains until a program is withdrawn or forcibly removed|
| |and its file is released. |
| | |
| | |
| | |

Case 2: Deadlocks in Databases

|P1 accesses R1 and locks it. |Deadlock can occur if 2 processes access & lock records in |
| |database. |
|P2 accesses R2 and locks it. | |
| |3 different levels of locking : |
|P1 requests R2, which is locked by P2. |Entire database for duration of request |
| |A subsection of the database |
|P2 requests R1, which is locked by P1. |Individual record until process is completed. |
| | |
| |If don’t use locks, can lead to a race condition. |

Case 3: Deadlocks in Dedicated Device Allocation

|P1 requests tape drive 1 and gets it. |Deadlock can occur when there is a limited number of dedicated |
| |devices. |
|P2 requests tape drive 2 and gets it. | |
| |E.g., printers, plotters or tape drives. |
|P1 requests tape drives 2 but is blocked. | |
| | |
|A P2 requests tape drive 1 but is blocked. | |

Case 4: Deadlocks in Multiple Device Allocation

| |Deadlocks can happen when several processes request, and hold on |
| |to, dedicated devices while other processes act in a similar |
| |manner. |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |

Case 5: Deadlocks in Spooling

• Most systems have transformed dedicated devices such as a printer into a sharable device by installing a high-speed device, a disk, between it and the CPU. • Disk accepts output from several users and acts as a temporary storage area for all output until printer is ready to accept it (spooling). • If printer needs all of a job's output before it will begin printing, but spooling system fills available disk space with only partially completed output, then a deadlock can occur.

Case 6: Deadlocks in Disk Sharing
[pic]

• Disks are designed to be shared, so it’s not uncommon for 2 processes to access different areas of the same disk. • Without controls to regulate use of disk drive, competing processes could send conflicting commands and deadlock the system. • Process P1 wishes to show a payment so it issues a command to read the balance, which is stored in cylinder 20 of a disk. • While the control unit is moving the arm to cylinder 20, P1 is put on hold and the I/O channel is free to process the next I/O request. • P2 gains control of the I/O channel and issues a command to write someone else’s payment to a record stored in cylinder 310. If the command is not locked out, P2 will put on hold while the control unit moves the arm to cylinder 310. • Because P2 is on hold, the channel is free to be captured again by P1, which reconfirms its command to read from cylinder 20. • Since the last command from P2 forced the arm mechanism to cylinder 310, the disk control unit begins to reposition the arm to cylinder 20 to satisfy P1. The I/O channel would be released because P1 is once again put on hold, so it could be captured by P2, which issues a WRITE command only to discover that the arm mechanism needs to reposition.

Case 7: Deadlocks in a Network

| | |
|A network that’s congested (or have filled large percentage of | |
|its I/O buffer space) can become deadlocked if it doesn’t have | |
|protocols to control flow of messages through network. | |
| | |
|For example: | |
|A medium-sized word processing center has seven computers on a | |
|network, each on different nodes. C1 receives messages from nodes| |
|C2, C6, C7 and sends messages only to C1. | |
| | |
|C2 receives message from C1, C3 and C4 and sends messages only to| |
|C1 and C3. | |
| | |
|Messages received by C1 from C6 and C7 and destined for C2 are | |
|buffered in an output queue. | |
| | |
|Messages received by C2 from C3 and C4 and destined for C1 are | |
|buffered on an output queue. | |
| | |
|As the traffic increases, and both buffer space is filled. At | |
|this point, C1 can’t accept any more messages (from C2 or any | |
|other computer) because there’s no more buffer space available to| |
|store them. | |
| | |
| | |
|For the same reason, C2 can’t accept any messages from C1 or any | |
|other computer, not even a request to send. | |
|The communication path between C1 and C2 become deadlocked and | |
|since C1 and receive message only from C6 and C7 those routes | |
|also become deadlocked. | |

3. Four Conditions for Deadlock

• Deadlock preceded by simultaneous occurrence of four conditions that operating system could have recognized:

a) Mutual exclusion b) Resource holding c) No preemption d) Circular wait

a) Mutual exclusion The act of allowing only one process to have access to a dedicated resource.

[pic]

b) Resource holding The act of holding a resource and not releasing it; waiting for the other job to retreat. [pic]

c) No preemption The lack of temporary reallocation of resources; once a job gets a resource it can hold on to it for as long as it needs.

[pic]

d) Circular wait Each process involved in impasse is waiting for another to voluntarily release the resource so that at least one will be able to continue.

[pic]

4. Modeling Deadlocks Using Directed Graphs (Holt, 1972)

• Processes represented by circles. • Resources represented by squares. • Solid line from a resource to a process means that process is holding that resource. • Solid line from a process to a resource means that process is waiting for that resource. • Direction of arrow indicates flow. • If there’s a cycle in the graph then there’s a deadlock involving the processes and the resources in the cycle.

Directed Graph Examples

[pic]

• Resource types R1, R2, . . ., Rm • eg : CPU cycles, memory space, I/O devices

• Each resource type Ri has Wi instances. • R1 has 4 instances eg 4 printers in a system • R2 has 2 instances eg 2 disk drive in a system • R3 has 1 instance eg 1 CPU in a system

R1 R2 R1

5. Reducing Directed Resource Graphs

i. Find a process that is currently using a resource and not waiting for one. Remove this process from graph and return resource to “available list.” ii. Find a process that’s waiting only for resource classes that aren’t fully allocated. – Process isn’t contributing to deadlock since eventually gets resource it’s waiting for, finish its work, and return resource to “available list.” iii. Go back to Step 1 and continue the loop until all lines connecting resources to processes have been removed.

5.1.

[pic]

No deadlock, because P3 has no requests, after P3 has finish its execution will release the resource R3 to P2 for execution progress. When P2 has finish, P2 will release the resources R2 and R3, finally the process P1 can gain the R2 for its execution.

5.2.
[pic]

Deadlock, because the all processes (P1, P2 and P3) in the system are waiting a resource which held by each process in the system. Every process is waiting each other process’s resource in the system.

5.3.

[pic]

Deadlock, because the all processes (P1, P2, P3 and P4) in the system are waiting a resource which held by each process in the system. Every process is waiting each other process’s resource in the system.

5.4.
[pic]

No deadlock, because all the processes (P1, P2 and P3) have no requests, so all the processes can make its execution progress.

5.5.
[pic]

Deadlock, because the all processes (P1, P2, and P3) in the system are waiting a resource instance which held by each process in the system. Every process is waiting each other process’s resource instance in the system.

5.6.

[pic]

No Deadlock, P2 has no request, after P2 finish, the process will release an instance of R2 to P3 for progression after P3 finish, it will release the instance of R1 to P1 for execution, finally all the processes request in the system have been served.
7. Converting the system scenario below into directed resource graphs

Consider a system of 4 processes, P = {P1, P2, P3, P4} and 4 resources types, R = {R1, R2, R3, R4}. Assume all the resources are non-sharable and the numbers of instances for each resource type are 4, 2, 2 and 2 respectively. Given the process states as follows:

o P1 holds all instances of R1, an instance of R3 and an instance of R4 and requests an instance of R2 o P2 holds an instance of R2 and requests an instance of R4 o P3 holds an instance of R2 and requests an instance of R3 o P4 holds an instance of R3 and R4

6. Strategies for Handling Deadlocks

• Prevent one of the four conditions from occurring.

• Avoid the deadlock if it becomes probable.

• Detect the deadlock when it occurs and recover from it gracefully.

7. Prevention of Deadlock

• To prevent a deadlock OS must eliminate 1 out of 4 necessary conditions. o Same condition can’t be eliminated from every resource.

a. Mutual exclusion is necessary in any computer system because some resources (memory, CPU, dedicated devices) must be exclusively allocated to 1 user at a time. o Might be able to use spooling for some devices. o May trade 1 type of deadlock (Case 3) for another (Case 5).

b. Resource holding can be avoided by forcing each job to request, at creation time, every resource it will need to run to completion. o Significantly decreases degree of multiprogramming. o Peripheral devices would be idle because allocated to a job even though they wouldn't be used all the time.

c. No preemption could be bypassed by allowing OS to deallocate resources from jobs. o OK if state of job can be easily saved and restored. o Bad if preempt dedicated I/O device or files during modification.

d. Prevention of Circular Wait o Circular wait can be bypassed if OS prevents formation of a circle. o Havender’s solution (1968) is based on a numbering system for resources such as:

Printer = 1, Disk = 2, Tape= 3.

– Forces each job to request its resources in ascending order. – Any “number one” devices required by job requested first; any “number two” devices requested next …

o Require that jobs anticipate order in which they will request resources.

Disk (2) Printer (1)

8. Deadlock Avoidance

• Even if OS can’t remove 1 condition for deadlock, it can avoid one if system knows ahead of time sequence of requests associated with each of the active processes.

• Dijkstra’s Bankers Algorithm (1965) used to regulate resources allocation to avoid deadlock.

• Safe state o If there exists a safe sequence of all processes where they can all get the resources needed. • Unsafe state o Doesn’t necessarily lead to deadlock, but it does indicate that system is an excellent candidate for one.

8.1 Banker’s Algorithm

• Based on a bank with a fixed amount of capital that operates on the following principles: – No customer will be granted a loan exceeding bank’s total capital. – All customers will be given a maximum credit limit when opening an account. – No customer will be allowed to borrow over the limit. – The sum of all loans won’t exceed the bank’s total capital.

• OS (bank) must be sure never to satisfy a request that moves it from a safe state to an unsafe one. • Job with smallest number of remaining resources < = number of available resources
8.2 A Bank’s Safe and Unsafe States

Safe

Unsafe

Example 1

Magnetic tape drives

To illustrate, we consider a system with 12 magnetic tape drives and 3 processes: P0, P1 and P2. P0 requires 10 tape drives, P1 may needs as many as 4 tape drives and P2 may need up to 9 tape drives.

Suppose that, at time t0, process P0 is holding 5 tape drives, P1 is holding 2 tape drives and P2 is holding 2 tape drives. (Thus, there are 3 free tape drives)

Processes Allocation (Alloc) Maximum needs (Max) Current Needs(Max – Alloc) P0 5 10 5 P1 2 4 2 P2 2 9 7

Banker’s Algorithm

| |Allocation (Alloc) |Maximum |Current Need |Availability |
|Processes |(Tape drive) |(Max) |(Max-Alloc) |(Avai) |
| | |(Tape drive) |(Tape drive) |(Tape drive) |
|P0 |5 |10 |5 |3 |
|P1 |2 |4 |2 |10 |
|P2 |2 |9 |7 |12 |

At time t0 ( the system is in a safe state

Because if with the sequence satisfies the safety condition. P1 can immediately be allocated all its tape drives and then return them (the system will then have 5 available tape drives); then P0 can get all its tape drives and return them (the system will then have 10 available tape drives); and finally P2 can get all its tape drives and return them (the system will then have all 12 tape drives available)

Magnetic tape drives

Banker’s Algorithm

| |Allocation (Alloc) |Maximum |Current Need |Availability |
|Processes |(Tape drive) |(Max) |(Max-Alloc) |(Avai) |
| | |(Tape drive) |(Tape drive) |(Tape drive) |
|P0 |5 |10 |5 |2 |
|P1 |2 |4 |2 |4 |
|P2 |3 |9 |6 | |

At time t1 (P2 requests and is allocated one more tape drive) ( the system in an unsafe state.

Because at this point, only P1 can be allocates all its tape drives. When it returns them, the system will have only 4 available tape drives. Since P0 is allocated 5 tape drives but has a maximum of 10, it may request 5 more tape drives. Since they are unavailable, P0 must wait, and this resulting in a deadlock.
Example 2

Consider a system with 5 processes P0 through P4 and 3 resources types A, B and C. Resources type A has 10 instances, resource B has 5 and resource C has 7. Suppose that, at time T0, the following snapshot of the system has been taken:

|Pn |Allocation |Max |Availability |
| |(A B C) |(A B C) |(A B C) |
|P0 |0 1 0 |7 5 3 |3 3 2 |
|P1 |2 0 0 |3 2 2 | |
|P2 |3 0 2 |9 0 2 | |
|P3 |2 1 1 |2 2 2 | |
|P4 |0 0 2 |4 3 3 | |

Answer the following questions using the banker’s algorithm:

a. What is the content of the matrix Need?

b. Is the system in a safe state, if yes states the process sequence? Justify your answer.
a.

|Pn |Allocation |Max |Current Need |Availability |
| |(A B C) |(A B C) |(A B C) |(A B C) |
|P0 |0 1 0 |7 5 3 | |3 3 2 |
|P1 |2 0 0 |3 2 2 | | |
|P2 |3 0 2 |9 0 2 | | |
|P3 |2 1 1 |2 2 2 | | |
|P4 |0 0 2 |4 3 3 | | |

9. Starvation

• Starvation -- Result of conservative allocation of resources where a single job is prevented from execution because it’s kept waiting for resources that never become available.

• Starvation occurs when one or more threads in your program are blocked from gaining access to a resource and, as a result, cannot make progress. Deadlock, the ultimate form of starvation, occurs when two or more processes/threads are waiting on a condition that cannot be satisfied. Deadlock most often occurs when two (or more) processes/threads are each waiting for the other(s) to do something.

• “The dining philosophers” Dijkstra (1968).

Figure 9.1
| |
|Five philosophers meet to think and to eat spaghetti. There are forks on the table - one between |
|each philosopher. Local custom dictates that each philosopher must use two forks to eat the |
|spaghetti, but there are only five forks available instead of ten. |
| |
|Unless the resources are allocated fairly, some philosophers will starve. |
| |
|[pic] |

• 5 philosophers are sitting at around table, each deep in thought and in the center lays a bowl of spaghetti that is accessible to everyone. Refer Figure 9.1. • Assume that each philosopher must use two forks to eat the spaghetti. There are only five forks. • When they sit down to dinner, Philosopher 1 (P1) is the first to take the two forks (F1 and F5) on either side of the plate and begins to eat. Inspired by his colleague, Philosopher 3 (P3) does likewise , using F2 and F3 • Now philosopher 2 (P2) decided to begin the meal but is unable to start because no forks are available. • F1 has been allocated to P1and F2 has been allocated to P3. The remaining fork can be used by P4 or P5, So Philosopher 2 must wait. • P4 and P5 are quietly thinking and P1 still eating when P3 (who should be full) decides to eat some more and because the resources are free, he is able to take F2 and F3 one again. Soon thereafter, P1 finishes and release F1 and F5 but P2 is still not able to eat because F2 is now allocated. • This scenario could continue forever and as long as P1 and P3 alternate their use of the available resources, P2 must wait. P1 and P3 can eat any time they wish while P2 starves.

• Avoid starvation via algorithm designed to detect starving jobs which tracks how long each job has been waiting for resources (aging).

-----------------------
[pic]

[pic]

Disk control unit

I/O Channel

P1 Read records at cylinder 20

P2 Write to file at cylinder 310

[pic]

P2

P1

P0

P2

P1

P0

[pic]

[pic]

P1

P21

Similar Documents

Free Essay

Boolean Assignment

...TR PT1420 5/13/14 Unit Assignment 4 l. What is the general fom1at of the statement used to code decisions in an application? A power full asset of the computer is its ability to make decisions and to take alternate course of action based on the outcome. 2. What is a Boolean expression? a logical statement that is either TRUE or FALSE. 3 . Explain the purpose of comparison operators and logical operators. The purpose of a comparison operator is to test some kind of relationship between two entities examples are >, <, ==, !=, etc 4. How does a comparison performed on numeric data differ from a comparison performed on string data? There are commonly used interchangeably, and the distinction between them is a small one. Comparison to" should be used when comparison is made between specific people, things, or other instances. 5. How does Visual Basic compare the Text property of a text box? When you compare the Text property of a text box with another value the Text property behaves like a variant. Visual Basic compares one text box to another as strings and compares a text box to a numeric variable or constant with a numeric compare. You can force a numeric comparison on a Text property by using the Val function. 6 . Why would it be useful to include the ToUpper method in a comparison? When comparing strings, the case of the characters is important. An uppercase “Y” does not compare equal to a lowercase “y”. Since the user may type a name or word in either...

Words: 902 - Pages: 4

Free Essay

Assignment of Income Doctrine

...ACC 616 Prof. Robert Simpson Student name: On the back Assignment 1: Explain Assignment of Income Doctrine The "assignment of income" doctrine states that income is taxed to the one who actually earns it. That means a taxpayer cannot avoid tax liability by assigning his income to another party or entity. Therefore, to be able to shift income to someone else, that one must actually earn the income. This doctrine aims to against the tax evasion when the taxpayer tries to deflect income to another party. First, starting from the term “earning”, earnings can occur either through the direct efforts of the taxpayer or the taxpayer’s ownership of an asset that generates income. Based on that understanding about earning, there are 2 ways to shifting income from one to another: the transferee must really work to earn that income or share the ownership of an asset that creates income. For example, if you are an owner of a business and you want to shift one part of your income to your family member such as your son, you need to hire your son to work for your company and give him the pay rate that is appropriate with his job. And the other way is to share your investment income with him, same meaning with sharing your ownership with him. The assignment of income applies the “tree and fruit” metaphor, in which the fruits cannot be attributed to a different tree from that on which they grew. If you want to avoid the tax liability on the fruit from the tree, you must prove that the...

Words: 421 - Pages: 2

Premium Essay

Assignment 2

...2.20 Write an SQL statement to display unique WarehouseIDs. SELECT DISTINCT WarehouseID FROM INVENTORY; 2.29 Write an SQL statement to display the SKU, SKU_Description, WarehouseID, and QuantityOnHand for all products having a QuantityOnHand greater than 1 and less than 10. Do not use the BETWEEN keyword. SELECT SKU, SKU_Description, WarehouseID, QuantityOnHand FROM INVENTORY WHERE QuantityOnHand > 1 AND QuantityOnhand < 10; 2.31 Write an SQL statement to show a unique SKU and SKU_Description for all products having an SKU description starting with ‘Half-dome’. SELECT DISTINCT SKU, SKU_Description FROM INVENTORY WHERE SKU_Description LIKE 'Half-dome%'; 2.33 Write an SQL statement to show a unique SKU and SKU_Description for all products having a ‘d’ in the third position from the left in SKU_Description. SELECT DISTINCT SKU, SKU_Description FROM INVENTORY WHERE SKU_Description LIKE '__d%'; 2.36 Write an SQL statement to display the WarehouseID and the sum of QuantityOnHand, grouped by WarehouseID. Name the sum TotalItemsOnHand and display the results in descending order of TotalItemsOnHand. SELECT WarehouseID, SUM(QuantityOnHand) AS TotalItemsOnHand FROM INVENTORY GROUP BY WarehouseID ORDER BY SUM (QuantityOnHand) DESC; 2.42 Write an SQL statement to display the SKU, SKU_Description, WarehouseID, Ware- houseCity, and WarehouseState of all items not stored in the Atlanta, Bangor, or Chicago warehouse. Do not use the...

Words: 349 - Pages: 2

Free Essay

Week 5 Assignment

...Janell Taylor 10/23/12 Implicit Test I found the test to be very interesting and I don’t like timed tests because I need time to think about my answer to be sure and confident about my choice. I don’t agree with the results because they said I made too many errors and I don’t understand that because that was just one part where I was making too many errors. It has helped me out in those areas of different topics, but I just wish I had more time. I guess I would say that the answers wasn’t valid enough for me because it didn’t really give me a score because I made too many errors, so I don’t agree with that too much. I believe prejudice is difficult to measure because I don’t agree with it and don’t like the fact that it’s very big and can get worse if we don’t come together to get in one accord to help each other and make the world better to live in dealing with different people and feelings. I think measuring prejudice can be a tough thing to deal with and handle because of the many people that are prejudice, which are hurting and harming many situations and people that’s trying to make it while being equal to everyone regardless of what. I would have to take the test over to get a better score because I felt that wasn’t fair because I made too many errors to get a...

Words: 252 - Pages: 2

Free Essay

Mat222 Week 1 Assignment.

...Solving Proportions MAT222 Week 1 Assignment September 22, 2014 Solving Proportions Solving for a proportion can be used within numerous real-world problems, such as finding the population of an area. Conservationists are able to predict the population of bear’s in their area by comparing information collected from two experiments. In this problem, 50 bears in Keweenaw Peninsula were tagged and released so conservationists could estimate the bear population. One year later, the conservationist took random samples of 100 bears from the same area, proportions are able to be used in order to determine Keweenaw Peninsula’s bear population. “To estimate the size of the bear population on the Keweenaw Peninsula, conservationists captured, tagged, and released 50 bears. One year later, a random sample of 100 bears included only 2 tagged bears. What is the conservationist’s estimate of the size of the bear population (Dugolpolski, 2012)?” In order to figure the estimated population, some variables need to first be defined and explain the rules for solving proportions. The ratio of originally tagged bears to the entire population is (50/x). The ratio of recaptured tagged bears to the sample size is (2/100). 50x=2100 is how the proportion is set up and is now ready to be solved. Cross multiplication is necessary for this problem. The extremes are (100) and (50). The means are (x) and (2). 100(50)=2x New equation, and now solve for (x). 50002=2x2 Divide both...

Words: 608 - Pages: 3

Free Essay

Mat222 Week 1 Assignment

...conservationist’s estimate of the size of the bear population? You will notice while reading question #56 on page 437, we are to assume that the ratio of originally tagged bears to the whole population is equal to the ratio of recaptured tagged bears to the size of the sample. The ratio of originally tagged bears to the whole population is 50X The ration of recaptured tagged bears to the sample size is 2100 50X=2100 This is the proportion set up and ready to solve. I will cross multiply setting the extremes equal to the means. 10050=2x 100and 50 are the extremes, while X and 2 are the means. 50002=2x2 Divide both sides by 2 X = 2500 The bear population on the Keweenaw Peninsula is around 2500 bears. The second problem for assignment one week one I am asked to solve the below equation for y. The first thing I notice is that a single fraction (ratio) on both sides of the equal sign so basically it is a proportion which can be solved by cross multiplying the extremes and the means. y-1x+3=-34 Is the equation I am asked to solve. 3y-1=-3x-4 The result of the cross multiplying. 3y-3=-3x+12 Distribute 3 on the left side and -3 on the right. 3y-3+3=-3x+12+3 Subtract 3 from both sides. 3y=-3x+15 3y3=-3x3+153 Divide both sides by 3 y=-x+5 This is a linear equation in the form of y=mx+b. This equation is in its simplest form. I like how we can take just a couple of numbers from a word equation and put it in an order that will help us solve many estimates...

Words: 340 - Pages: 2

Premium Essay

Pt1420 Unit 3 Assignment

...6.1) Comparison of three numbers Problem is of comparison of values among three values , a very simple problem. Here, the decision making process is done based on the value of the parameters a,b and c. The data types of all these variables are interger. 6.2) Binary search A binary search locates the position of an item in a sorted array. Binary search works by comparing an input value to the middle element of the array. The comparison determines whether the element equals the input, less than the input or greater. When the element being compared to equals the input the search stops and typically returns the position of the element. If the element is not equal to the input then a comparison is made to determine whether the input is less than or greater than the element. Depending on which it is the algorithm then starts over but only searching the top or bottom subset of the array's elements. If the input is not located within the array the algorithm will usually output a unique value indicating this. Binary search algorithms typically halve the number of items to check with each successive iteration, thus locating the given item (or determining its absence) in logarithmic time. A binary search is a dichotomic divide and conquer search algorithm. 6.3) Quadratic problem In Quadratic equation solver problem(called the procedure under test) is chosen. This procedure has three predicates involving both linear and non-linear functions of the input variables. In this there are three...

Words: 728 - Pages: 3

Free Essay

Mobile Service Provider

...11108944 Name: ASHWINI KUMAR Roll No. : RE3R02B32 PART- A 1. Ans :- (a) unary and ternary operator Unary operator:- It pecedes an operand . The operand (the value on which the operator operates ) of the unary operator must have arithmetic or pointer type and the result is the value of the argument. Example:- If a=5 then +a means 5 If a=0 then +a means 0. If a=-4 then +a means -4. Ternary operator:- It precedes an operand. The operand of the unary operator must have arithmetic type and the result is the negation of the operand’s value. Example:- If a=5 then –a means -5 If a=0 then –a means 0 If a=-4 then –a means 4. (b) Assignment and equalto operator Assignment operator:- Equal to operator: An assignment operator assigns value In this we put the To a variable. value as it is. Example – Example- a*=5 means a=5*5. Int a; a=5 means a is initialized with 5 if(a==5) { return true; } return false; (c) Expression and statement Expression:- An expression is any valid combination of operators , constants , and variables. Example:- ...

Words: 399 - Pages: 2

Premium Essay

Student

...Problem Solving with Computing Homework - WEEK 2 [30 points] This is a review of some of the material from Chapter 2 and lectures from class. No credit for answers that are copies or near verbatim transcripts – please use your own words1 and document sources where appropriate. 1 This will apply to all assignments in this class. Answer the following questions: Chapter 2 1. Short Answers [1 point each, 2 points total] 1. What does a professional programmer usually do first to gain an understanding of a problem? The first thing that a professional programmer usually do first to gain an understanding of a program is to closely relate customer (Interview ) to inquire or gather information about the problem. 2. What two things must you normally specify in a variable declaration? The two things normally specified in a variable declaration are the variable type and identifier. 2. Algorithms / Pseudocode [1 point each, 5 points total] 1. Design an algorithm that prompts the user to enter his or her height and stores the user’s input in a variable named height. Declare height Display “Enter Your Height” Input Height Display “Height” 2. Write assignment statements that perform the following operations with the variables a and b. - Adds 2 to a and stores the result in b. - Subtracts 8 from b and stores the result in a Set b=2+a Set a=b-8 3. Write a pseudocode statement that declares the variable cost so it can hold real numbers. Floating Point-Variable...

Words: 1823 - Pages: 8

Free Essay

Prg/211 Calorie Count Tool

...Team B Calorie Count Tool PRG/211 May 5, 2014 Team B Calorie Count Tool PROBLEM STATEMENT Team B was asked to develop a program which would calculate the user’s daily intake of calories and measure those calories against the overall calories expended. The core purpose of this program will do two primary functions. First, it will record the user intake of calories as acquired through meals throughout the day. Second, the user will record caloric output associated with physical activity. This information will be calculated together to determine the caloric surplus or deficit for the user. In order for the program to execute accurately, and provide customized results, the user will be required to input personal data to include gender, age, weight, and height. This additional information is essential to determine the user’s default caloric burn rate, otherwise known as the basal metabolic rate (BMR). The BMR and the calories burned as a result of physical activity will be calculated against the intake of calories to determine the overall success for the user. As the program is executed it must: * Record user name, age, height, weight to enable more accurate calculations * Record the users specific caloric values entered for each meal * Record the user activity and caloric burn values for that activity * Calculate the basal metabolic rate (BMR) for the individual * Subtotal the total caloric values for the day * Combine the physical activity and...

Words: 1524 - Pages: 7

Premium Essay

Week 2 Assigment

...Week 2 Assignment: Understanding Effective Money Management Assessment A, Part 1: Creating a Personal Financial Statement - Assets | 1 point | Car: Bluebook value $1250.00Cash: $378.00Savings Accounts: $826.00 | Assessment A, Part 2: Creating a Personal Financial Statement - Debts | 1 point | Rent: $750.00Electric/ Gas bill: $131.75Cable/ internet/ Phone bill: $80.42Credit Card: $31.00Cell phone bill: $72.37 | Assessment A, Part 3: Identify Money Management Tool | 1 point | Explain to Monica how the money management tools were identified. | Students should explain how they evaluated various cash management products and services. | Assessment A, Part 4: Creating a Personal Financial Statement – Steps | 1 point | Drag the steps listed on the right into their correct sequences on the left. When done click the Send button | Step 1: I got all my financial stuff together – bills, loans, bank statements, etc. | Step 2: I balance my checkbook. | Step 3: I decided what were my assets and what were my debts. | Step 4: I enter my assets in the program. | Step 5: I enter my debts in the program. | Step 6: The program gave me a Net worth figure at the end. | Assessment B: Creating a Monthly Cash Flow Statement ...

Words: 255 - Pages: 2

Premium Essay

Andy Owes Bill a Debt.

...Law Written Assignment 3 Case Study 1 Parks, a 7-foot, 265-pound center for the San Diego Slick, objected when his contract was assigned from the ABC Corporation to the XYZ Corporation, the team’s new owner. The change of owners did not cause a change in the composition of the team although a new coach was hired. Parks’s compensation and his responsibilities remained the same. Was this contract assignable? Facts of the Case: 1) Parks contract was assigned from the ABC Corporation to XYZ Corporation. 2) Parks compensation and his responsibilities remained the same. Issues: 1) The reason why we are in court today is to identify if Park’s contract was assignable. Rules of the Law: 1) Personal Service Contract – The parties agree that a personal service contract may be assigned. This allows the trade of an athlete from one team to another team. 2) Notice of Assignment – Assignee is under a duty to notify the obligor that the assignment has been made and performance must be rendered to the assignee. 3) Anti-Assignment Clause – Prohibits the assignment of rights under the contract. 4) Approval Clause – requires that the obligor approves any assignment of contract. Analysis & Conclusion: Since we do not have all the facts we can assume the following: 1) Parks contract did include the Personal service contract. 2) Notice of assignment was made by XYZ Corporation. 3) Parks contract did NOT include Anti-Assignment Clause. ...

Words: 495 - Pages: 2

Free Essay

Eopp

...Reflection assignment In this assignment I will be using the Gibbs Reflective Model, reference, to reflect on an incident that occurred in placement that demonstrates an understanding of the Outcome : 3.1: Demonstrate that they respect diversity and individual preferences and value differences, regardless of their own personal views. To do this I will first, briefly describe the event, supporting my outline with relevant information. I will then explore the event, and discuss why it is important and how it relates to the learning outcome. I will also be discussing why materials such as law and guidelines say this is important. I will then proceed to analyse the incident by breaking it down and picking out the main features of the experience, discussing why they are important, whilst linking the main points together. I will attempt to think about opposing arguments to what I have explored, and discuss the advantages and disadvantages of the arguments. Finally I will be using SMART goals, to create an action plan for future development. Explain incident with evidence Whilst on a shift, we had an elderly patient arrive on the ward. The patient suffered from a Frank Haematuria, Colovesciular fistula as well as incontinence. It was suggested that the patient received surgery to have this corrected, but the patient refused surgery, stating that at his age he did not want to go through with it, and wanted to put a DNAR in place. I along with the other nurses respected his choice...

Words: 370 - Pages: 2

Free Essay

Misconceptions of Algebra

...Diagnostic Algebra Assessment Definitions Categories Equality Symbol Misconception Graphing Misconception Definition Concept of a Variable Misconception Equality Symbol Misconception As algebra teachers, we all know how frustrating it can be to teach a particular concept and to have a percentage of our students not get it. We try different approaches and activities but to no avail. These students just do not seem to grasp the concept. Often, we blame the students for not trying hard enough. Worse yet, others blame us for not teaching students well enough. Students often learn the equality symbol misconception when they begin learning mathematics. Rather than understanding that the equal sign indicates equivalence between the expressions on the left side and the right side of an equation, students interpret the equal sign as meaning “do something” or the sign before the answer. This problem is exacerbated by many adults solving problems in the following way: 5 × 4 + 3 = ? 5 × 4 = 20 + 3 = 23 Students may also have difficulty understanding statements like 7 = 3 + 4 or 5 = 5, since these do not involve a problem on the left and an answer on the right. Falkner presented the following problem to 6th grade classes: 8 + 4 = [] + 5 All 145 students gave the answer of 12 or 17. It can be assumed that students got 12 since 8 + 4 = 12. The 17 may be from those who continued the problem: 12 + 5 = 17. Students with this misconception may also have difficulty with the idea that adding...

Words: 797 - Pages: 4

Free Essay

Book Report

...Selection statements Selection is used to select which statements are to be performed next based on a condition being true or false. Relational expressions In the solution of many problems, different actions must be taken depending on the value of the data. The if statement in C I used to implement such s decision structure in its simplest form – that of selecting a statement to be executed only if a condition is satisfied. Syntax: if(condtion) statement executed if condition is true When an executing program encounters the if statement, the condition is evaluated to determine its numerical value, which is then interpreted as either true or false. If the condition evaluates to any non-0 value (positive or negative), the condition is considered as a “true” condition and the statement following the if is executed; otherwise this statement is not executed. Relational Operators In C Relational operator | Meaning | Example | < | Less than | age < 30 | > | Greater than | height > 6.2 | <= | Less than or equal to | taxable <= 200000 | >= | Greater than or equal to | temp >= 98.6 | == | Equal to | grade == 100 | != | Not equal to | number !=250 | In creating relational expressions, the relational operators must be typed exactly as given in the above table. Thus, although the following relational expressions are all valid: age > 40 length <= 50 temp >= 98.6 3 < 4 flag == done day != 5 The following are invalid: length =< 50 ...

Words: 1617 - Pages: 7