1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
mojhsa [17]
3 years ago
10

Here are the codes for producer and consumer problems.

Computers and Technology
1 answer:
melomori [17]3 years ago
3 0

Answer:

If a switch happens during counter++ or counter--, we will get a wrong value for the counter.

Explanation:

counter++ counter--

register1 = counter register2 = counter

register1 = register1 + 1 register2 = register2 - 1

counter = register1 counter = register2

Lets consider this example, lets assume that counter=4, this simply means that there are 4 items which are produced already. Lets look at the following steps and value of counter after each step.

a) Producer process is updating counter++, this takes place at machine level, also, during that when it completed register1=counter counter=4

b) Supposing we have a context switch happen to consumer process and it is trying to update counter--, this takes place at machine level, also when it completed

register2=counter counter=4

register2=register2-1

counter=register2 counter=3

c) Lets assume that context switch happened back to producer process and it continues from where it stopped, look at step a

register1=register1+1

counter=register1 counter=5

This will make the value of counter variable to become 5. Consumption of one item is not reflected in the counter variable. To avoid this we need to allow the atomic execution of all these instructions. This implies completion of any updates on the counter, while others wait for its completion.

d) In the event a producer executes all these machine level instructions at once,then there is no inconsistency on this.

You might be interested in
The following SQL statement uses a(n) _____. SELECT P_CODE, P_DESCRIPT, P_PRICE, V_NAME FROM PRODUCT, VENDOR WHERE PRODUCT.V_COD
Trava [24]

Answer:

The answer is c. “old-style” join.

Explanation:

SELECT P_CODE, P_DESCRIPT, P_PRICE, V_NAME

FROM PRODUCT, VENDOR

WHERE PRODUCT.V_CODE = VENDOR.V_CODE;

The SELECT clause represents all the columns to be displayed.

The FROM clause represents the tables which are used to extract the columns.

The WHERE clause shows the common column that exists in both the tables. This represents the old-style join when JOIN keyword was not used.

The tables are joined in two ways.

1. Using JOIN keyword

The syntax for this is given as

SELECT column1, column2

FROM table1 JOIN table2

ON table1.column3 = table2.column3;

This returns all rows from two tables having the same value of common column.

Two tables are taken at a time when JOIN keyword is used.

If more tables are to be used, they are mentioned as follows.

SELECT column1, column2

FROM table1 JOIN table2

ON table1.column3 = table2.column3

JOIN table3

ON table3.column4 = table1.column4

( ON table3.column5 = table2.column5 )  

The part in italics shows that the third table can either share the same column with table1 or table2.

The given query can be re-written using JOIN as shown.

SELECT P_CODE, P_DESCRIPT, P_PRICE, V_NAME

FROM PRODUCT JOIN VENDOR

ON PRODUCT.V_CODE = VENDOR.V_CODE;

2. Equating common column in WHERE clause

SELECT column1, column2

FROM table1, table2

WHERE table1.column3 = table2.column3;

This returns all rows from two tables having the same value of the common column.

Here, no keyword is used except the general syntax of the query. ON keyword as shown in the above example is replaced with WHERE.

Tables to be used are mentioned in FROM clause separated by commas.

Tables are joined based on the same column having same values.

Multiple tables can be joined using this style as follows.

SELECT column1, column2

FROM table1, table2, table3, table4

WHERE table1.column3 = table2.column3

AND table3.column5=table1.column5

AND table3.column4 = table2.column4;

5 0
3 years ago
List the invoice number and invoice date for each invoice that was created for James Gonzalez but that does not contain an invoi
Ludmilka [50]

Answer:

Derive FROM invoice_transaction, invoice_details, item_details

and JOIN customer_details  ON (invoice_transaction.CUST_ID = customer_details.CUST_ID  AND customer_details.FIRST_NAME = 'James'   AND customer_details.LAST_NAME  = 'Gonzalez')

Explanation:

The following details will be there in the invoice

  1. item_details
  2. rep_details
  3. invoice_details
  4. customer_details
  5. invoice_transaction

 Derive FROM invoice_transaction, invoice_details, item_details

and JOIN customer_details  ON (invoice_transaction.CUST_ID = customer_details.CUST_ID  AND customer_details.FIRST_NAME = 'James'   AND customer_details.LAST_NAME  = 'Gonzalez')

6 0
2 years ago
A(n) ____ is an entry in a cell that contains text such as "2016 Sales" or "Travel Expenses."
slavikrds [6]

Answer:

B- label

Explanation:

A label is an entry such as a text within a cell that describes particular rows and columns. Labels are usually found at the top of the particular row/column they are identifying.

Hence, the texts "2016 Sales" and "Travel Expenses" are labels that identify cells such as the values of the sales in 2016 of a company and expenses spent on travel in a year of a family.

6 0
3 years ago
As we discussed in class, with the explosion of huge volumes of unstructured data, a new breed of database technologies have eme
Ronch [10]

Answer:

Dynamo, Bigtable, and Cassandra are NoSQL data stores being used by some of the worlds biggest IT businesses such as Amazon.

These programs were developed to solve a specific or unique business problem. The initial plan was not to commercialize them.

 

Cheers!

5 0
3 years ago
What is a resume?A collection of all your professional and artistic works.A letter which explains why you want a particular job.
mars1129 [50]

Answer:

a 1-2 page document that demonstrates why you are qualified for a job by summarizing your skills, education, and experience.

7 0
3 years ago
Other questions:
  • What is the most useful advantage of using the Slide Sorter view to rearrange slides instead of using the slide thumbnails in No
    5·1 answer
  • To use files in a c++ program you must include the ________ header file.
    15·1 answer
  • What is the 7 X 7 when referring to PowerPoint presentations?
    12·2 answers
  • Producers must understand the marginal benefit of making an additional unit which shows the ...
    5·2 answers
  • The person in charge of recording the sound should always
    15·1 answer
  • What subsection of the Internet requires specialized browser to access and is frequently used by cyber criminals and underground
    10·1 answer
  • You have several reference computers. The computers are configured to always start from a local hard disk drive. You plan to cap
    10·1 answer
  • Using more than one array to store related data is called _____________ arrays.
    7·2 answers
  • Question 2 of 10
    12·1 answer
  • Who was making the high-pitched growling noise that Francisco hears?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!