Process Synchronization: Producer-Consumer Problem
The purpose of this programming project is to explore process synchronization. This will be
accomplished by writing a program on the Producer / Consumer problem described below. Your
simulation will be implemented using Pthreads. This assignment is a modification to the
programming project “The Producer – Consumer Problem” found at the end of Chapter 7 of our
textbook. 1. Your program must be written using C or C++ and you are required to use the
Pthread with mutex and semaphore libraries.
In chapter 3, we discussed how a "bounded buffer" could be used to enable producer and
consumer processes to share memory. We described a technique using a circular buffer that can
hold BUFFER_SIZE-1 items. By using a shared memory location count, the buffer can hold all
BUFFER_SIZE items. This count is initialized to 0 and is incremented every time an item is
placed into the buffer and decremented every time an item is removed from the buffer. The
count data item can also be implemented as a counting semaphore.
The producer can place items into the buffer only if the buffer has a free memory location to
store the item. The producer cannot add items to a full buffer. The consumer can remove items
from the buffer if the buffer is not empty. The consumer must wait to consume items if the buffer
is empty.
The "items" stored in this buffer will be integers. Your producer process will have to insert
random numbers into the buffer. The consumer process will consume a number.
Assignment Specifications
The buffer used between producer and consumer processes will consist of a fixed-size array of
type buffer_item. The queue of buffer_item objects will be manipulated using a circular array.
The buffer will be manipulated with two functions, buffer_insert_item() and
buffer_remove_item(), which are called by the producer and consumer threads, respectively. A
skeleton outlining these functions can be found in buffer.h (provided with this assignment).
The buffer_insert_item() and buffer_remove_item() functions will synchronize the producer and
consumer using the algorithms. The buffer will also require an initialization function (not
supplied in buffer.h) that initializes the mutual exclusion object "mutex" along with the "empty"
and "full" semaphores.
The producer thread will alternate between sleeping for a random period of time and generating
and inserting (trying to) an integer into the buffer. Random numbers will be generated using the
rand_r() function. See the text on page 290 for an overview of the producer algorithm.
The consumer thread will alternate between sleeping for a random period of time (thread safe of
course) and (trying to) removing a number out of the buffer. See the text on page 290 for an
overview of the consumer algorithm.
The main function will initialize the buffer and create the separate producer and consumer
threads. Once it has created the producer and consu ...
Process Synchronization Producer-Consumer ProblemThe purpose o.docx
1. Process Synchronization: Producer-Consumer Problem
The purpose of this programming project is to explore process
synchronization. This will be
accomplished by writing a program on the Producer / Consumer
problem described below. Your
simulation will be implemented using Pthreads. This assignment
is a modification to the
programming project “The Producer – Consumer Problem”
found at the end of Chapter 7 of our
textbook. 1. Your program must be written using C or C++ and
you are required to use the
Pthread with mutex and semaphore libraries.
In chapter 3, we discussed how a "bounded buffer" could be
used to enable producer and
consumer processes to share memory. We described a technique
using a circular buffer that can
hold BUFFER_SIZE-1 items. By using a shared memory
location count, the buffer can hold all
BUFFER_SIZE items. This count is initialized to 0 and is
incremented every time an item is
placed into the buffer and decremented every time an item is
removed from the buffer. The
2. count data item can also be implemented as a counting
semaphore.
The producer can place items into the buffer only if the buffer
has a free memory location to
store the item. The producer cannot add items to a full buffer.
The consumer can remove items
from the buffer if the buffer is not empty. The consumer must
wait to consume items if the buffer
is empty.
The "items" stored in this buffer will be integers. Your producer
process will have to insert
random numbers into the buffer. The consumer process will
consume a number.
Assignment Specifications
The buffer used between producer and consumer processes will
consist of a fixed-size array of
type buffer_item. The queue of buffer_item objects will be
manipulated using a circular array.
The buffer will be manipulated with two functions,
buffer_insert_item() and
buffer_remove_item(), which are called by the producer and
consumer threads, respectively. A
skeleton outlining these functions can be found in buffer.h
(provided with this assignment).
3. The buffer_insert_item() and buffer_remove_item() functions
will synchronize the producer and
consumer using the algorithms. The buffer will also require an
initialization function (not
supplied in buffer.h) that initializes the mutual exclusion object
"mutex" along with the "empty"
and "full" semaphores.
The producer thread will alternate between sleeping for a
random period of time and generating
and inserting (trying to) an integer into the buffer. Random
numbers will be generated using the
rand_r() function. See the text on page 290 for an overview of
the producer algorithm.
The consumer thread will alternate between sleeping for a
random period of time (thread safe of
course) and (trying to) removing a number out of the buffer. See
the text on page 290 for an
overview of the consumer algorithm.
The main function will initialize the buffer and create the
separate producer and consumer
threads. Once it has created the producer and consumer threads,
the main() function will sleep
for duration of the simulation. Upon awakening, the main thread
4. will signal other threads to quit
by setting a simulation flag which is a global variable. The main
thread will join with the other
threads and then display the simulation statistics. The main()
function will be passed two
parameters on the command line:
• The length of time the main thread is to sleep before
terminating (simulation length in
seconds)
• The maximum length of time the producer and consumer
threads will sleep prior to
producing or consuming a buffer_item
A skeleton for the main function appears as:
#include <buffer.h>
int main( int argc, char *argv[] ){
Get command line arguments
Initialize buffer
Create producer thread(s)
Create consumer thread(s)
Sleep
5. Join Threads
Display Statistics
Exit
}
Creating Pthreads using the Pthreads API is discussed in
Chapter 4 and in Assignment-1. Please
refer to those references for specific instructions regarding
creation of the producer and
consumer Pthreads.
The following code sample illustrates how mutex locks
available in the Pthread API can be used
to protect a critical section:
#include <pthread.h>
pthread_mutex_t mutex;
/* create the mutex lock */
pthread_mutex_init( &mutex, NULL );
/* aquire the mutex lock */
pthread_mutex_lock( &mutex );
/*** CRITICAL SECTION ***/
/* release the mutex lock */
6. pthread_mutex_unlock( &mutex );
Pthreads uses the pthread_mutex_t data type for mutex locks. A
mutex is created with the
pthread_mutex_init() function, with the first parameter being a
pointer to the mutex. By passing
NULL as a second parameter, we initialize the mutex to its
default attributes. The mutex is
acquired and released with the pthread_mutex_lock() and
pthread_mutex_unlock() functions. If
the mutex lock is unavailable when pthread_mutex_lock() is
invoked, the calling thread is
blocked until the owner invokes pthread_mutex_unlock(). All
mutex functions return a value of
0 with correct operation; if an error occurs, these functions
return a nonzero error code.
Pthreads provides two types of semaphores: named and
unnamed. For this project, we will use
unnamed semaphores. The code below illustrates how a
semaphore is created:
#include <semaphore.h>
sem_t sem;
/* create the semaphore and initialize it to 5 */
7. sem_init( &sem, 0, 5 );
The sem_init() function creates and initializes a semaphore.
This function is passed three
parameters: A pointer to the semaphore, a flag indicating the
level of sharing, and the
semaphore's initial value. In this example, by passing the flag 0,
we are indicating that this
semaphore can only be shared by threads belonging to the same
process that created the
semaphore. A nonzero value would allow other processes to
access the semaphore as well. In
this example, we initialize the semaphore to the value 5.
In Chapter-6 (Section 6.6), we described the classical wait() and
signal() semaphore operations.
Pthread names the wait() and signal() operations sem_wait() and
sem_post(), respectively. The
code example below creates a binary semaphore mutex with an
initial value 1 and illustrates it
use in protecting a critical section:
#include <semaphore.h>
sem_t mutex;
/* create the semaphore */
8. sem_init( &mutex, 0, 1 );
/* acquire the semaphore */
sem_wait( &mutex );
/*** CRITICAL SECTION ***/
/* release the semaphore */
sem_post( &mutex );
Program Output
Your simulation should output when various conditions occur:
buffer empty/full, location of
producer/consumer, etc.
Submission Guidelines and Requirements
1. Your program must be written using C or C++ and you are
required to use the Pthread
with mutex and semaphore libraries
2. You may use the C/C++ STL (Standard Template Library) in
your solution.
3. You should use Netbeans to implement the assignment. You
can download Netbeans
with C/C++ features from the following link:
https://netbeans.org/downloads/8.2/
4. Create project in Netbeans for completing this assignment.
9. 5. Add comments (about the function/variable/class) to your
code as much as possible
BUSL 18 Memorandum
TO: BUSL 18 online (8 weeks) students
FROM: Catherine McKee
DATE: Spring 2020
RE: Briefing Assignment
Instructions:
Please brief People v. Simpson (1998) 65 Cal.App.4th 854 [76
Cal.Rptr.2d 851]], which is available in this same folder on
Canvas. Use the following format for your brief, including the
headings. Consult your book at pages A-1 through A-3 for an
explanation and an example of case briefing. You will notice
that my headings are slightly different from those in your book;
please use the headings below. Also, review pages 20-24 for an
overview of cases and and help understanding our case. For
those of you with the ebook (and no page numbers), this
material is under section 1-7, How to Read and Understand Case
Law, in chapter 1 of the book. Make sure you look at the
sample case in Exhibit 1-6 also.
People v. Simpson (1998) 65 Cal.App.4th 854 [76 Cal.Rptr.2d
851]
Facts: (This is the “story” that gives rise to the case. What
facts are at the root of the controversy? What is the defendant
accused of? Why was he arrested? Provide details that may be
important to the case. If in doubt, include more detail here
rather than less. Facts end with the arrest in a criminal case. 10
points.)
Procedural History: (This what happened in the lower court
system. Start this part with what the defendant is charged with.
Procedurally, what has happened in this case? What are the
10. legal theories (murder? Kidnapping? Possession? etc.) that the
prosecution is using? Was there a trial or a motion? Who won
it? Who is appealing? Why? 10 points.)
Issue: (This is the question that this appeals court is trying to
answer by hearing this case. There may be more than one
question. If so, state them all, each in a separate numbered
paragraph. Look for the appellant’s appeals argument(s). The
issues are often based on these arguments. The issues are
questions only, no background, no answers, just questions. 15
points.)
Result/Holding: (This is the answer to the issue. If there are
three issues, there will be three results. This is a good part to
quote. Number these and put each one in a separate short
numbered paragraph. 15 points.)
Reasoning: (The is the court’s explanation of how it went from
its issue to its result/holding. This is usually the longest part of
the brief. It’s the part where the justice discusses the
Constitution, cases/precedent, and/or statutes. Discuss each
issue in a separate paragraph. Follow the RAC format discussed
in chapter 1: rule/law, analysis/application, conclusion for each
issue. 25 points.)
Procedural Consequences: (Does this appeals court agree with
the trial court’s decision? Look for the “magic” words:
affirmed, reversed, modified, and/or remanded. This part is
usually just one sentence long. 5 points.)
Use this format, since part of your grade (20 points) will
be based on correct formatting. Your brief should be
typewritten, double-spaced, and at least two pages in length.
Use a font size of 11 or 12. Underline your headings. Indent
the first line of each paragraph. Pay attention to your grammar
and spelling, as I will deduct points for spelling and grammar
11. errors. I will look also for independent thinking and analysis.
This assignment assesses one of the student learning outcomes
(SLOs) for our class, briefing an appellate court case. It also
relates to some of the measurable course outcomes for our class:
· Compare and contrast civil and criminal procedures
· Evaluate the U.S. Constitution and the Bill of Rights
People v. Simpson is an appeals court CASE. You are writing a
BRIEF (summary) of this case. The brief is simply a summary
of the case, written in this particular format.
Case briefs are formal documents, although they are not
submitted to a court. They are simply case summaries that you
prepare so you can refer back to them later. Case briefs are
often prepared in law firms and legal departments of
corporations and other businesses. Also, if you go on to
business school or law school, you will learn by reading cases,
and you will prepare for class by preparing case briefs. Since
case briefs are formal documents, you must not use contractions
(don’t, can’t, won’t, wouldn’t, etc.), abbreviations, or slang
unless you’re quoting from the case. Refer to the people by
their last names, not their first names. The first time you refer
to Mr. Simpson, give his full name and say that he is the
defendant and appellant (party designations), but after that just
call him by his last name. Write your brief in past tense. Write
out dates rather than putting them in numeric (2/23/12) form.
It is okay to quote from the case but you MUST use quotation
marks if you quote. You are plagiarizing if you quote without
using quotation marks. You will also be plagiarizing if you
copy and paste from the case into your brief. Canvas will use
UniCheck to detect any possible plagiarism in the briefs. Do
not do any outside research or use any sources other than this
case and our textbook.
12. Read over the case several times before starting your brief.
Since you are not used to reading cases, it’s unlikely that you
will understand the case the first time you read it. This is very
normal! Organize before you start writing. Use quotation
marks when quoting from the case.
There are three documents that must be submitted as part of this
assignment:
· The brief evaluation form. By Sunday, March 29, at 11:55
p.m., you must evaluate your brief draft, complete the
evaluation form, and submit the completed form, which is
available on our Canvas page.Use the form to evaluate your own
brief draft. Students often lose points for items that are listed
on the evaluation form, so please go over your draft carefully
with the form.The brief evaluation is worth 5% of your course
grade. Upload your completed evaluation as a Canvas
assignment. I will review the evaluation forms and respond to
any questions you ask on the form.
· The brief. The brief is due by Sunday, April 5 at 11:55 p.m.,
uploaded on the Canvas page as a MS Word (.doc or .docx)
document. Name the document/attachment in the following
format: Last name, first name – brief 40294. Example: Garcia,
Lily – brief 40294. You will lose 5 points if you do not follow
this format. I do not accept late assignments. If you have any
questions about this assignment, please contact me via Canvas
Inbox, or visit me during my office hours.
When I finish grading all of the briefs from the class I will
return them electronically through the grades page, including
my comments. I hope to return these in about one week. I will
update you via Canvas if grading takes longer than one week.
PLGL 30/BUSL 18
Peer Evaluation of Brief
2019-2020
McKee
13. Name of student reviewing the brief draft: ________Yaxuan
Li_________________
Name of student who wrote the brief draft: _________Yaxuan
Li_____________________
Format: Are all of the following headings present, and are they
all bolded and underlined?
Title, complete with citation? (The case name and the numbers
and letters that indicate where to find the case. Just copy this
from the assignment sheet.)
Yes No
Facts?
Yes No
Procedural History?
Yes No
Issue?
Yes No
Result/Holding?
Yes No
Reasoning?
Yes No
Procedural Consequences?
Yes No
Facts: (10 points)
Do the facts tell the story behind the lawsuit? The lawsuit
should NOT be mentioned here. This should be the background
story that caused the lawsuit. Tell it chronologically. If in
doubt, make it more detailed rather than less detailed. Again,
do not include any court stuff here.
Yes No
Comments:
Did the author forget anything?
Yes No
14. Comments:
Are the facts clearly written so that you can understand them?
Yes No
Comments:
Procedural History: (10 points) All of these questions should
be answered “Yes.”
Does this section mention relevant motions, if any?
Yes No
Procedural History should start when the case enters the court
system (the plaintiff sues the defendant or the criminal
defendant is charged with a crime). Does it?
Yes No
Does this section mention the initial hearing or trial, if any?
Yes No
Does it mention who won that hearing/trial?
Yes No
If the plaintiff won any money at trial, does it specify how
much was awarded?
Yes No
If this is a criminal case, does the brief specify whether the
defendant was convicted by a jury, or did s/he plead guilty or no
contest?
Yes No
Does it mention who is appealing?
Yes No
Does it mention why that person/entity is appealing?
Yes No
Is this section written chronologically?
Yes No
Do not include the outcome of the appeal here. This section
should end with the arrival of this case at this appeals court.
Does this include the appellate outcome? If so, remove it.
15. Yes No
Issue: (15 points)
Has the author found the question(s) that this appeals court is
trying to answer? Look for the appellant's (the person who's
appealing) arguments on appeal. The issues are often based on
these arguments. Try writing each argument as a question.
Yes No
Comments:
Do you think the author phrased the question(s) clearly?
Yes No
Comments:
Does the issue end with a question mark? It doesn't have to end
in a question mark, but issues are often phrased as questions.
Yes No
Try to make the issues as specific as possible. One way to do
this is to try to include the following elements in each issue.
· Does the issue mention the governing law (case name, statute,
or amendment)? Y/N
· Does the issue quote the relevant language from that law?
Y/N
· Does the issue mention any relevant facts from our case? Y/N
If there is more than one issue, is each issue numbered, and
contained in a separate paragraph?
Yes No
This section should be questions only, no background and no
answers. Just questions. Does this section contain questions
only? If not, remove everything except the questions/issues.
Yes No
Result/Holding: (15 points)
Does this section answer the issue? The result/holding should
16. be more than simply “Yes,” “No,” or “Maybe.” There should be
a Result/Holding for each Issue, so if there are two Issues, there
will be two Results/Holdings. Number each Result/Holding,
and put each in a separate short paragraph. This is a good part
of the case to quote.
Yes No
Comments:
Please help the author find and phrase the answer:
Does this section contain any of the words “affirmed,”
“reversed,” or “remanded”? If so, this section is probably
incorrect. Those words should appear in the Procedural
Consequences.
Yes No
The Result/Holding should be an answer that is specific to this
case. It should not be just a general statement of law. Is the
Result/Holding specific to our specific case?
Yes No
Comments:
Reasoning: (25 points)
Please make sure that the author has not simply listed the cases
and sources that the judge used to decide the case. The author
must discuss the sources (cases, statutes) and explain how they
apply to our case.
Has the author focused on the appeals court’s decision here?
S/he should. The trial court’s decision can be mentioned here
because the appeal is usually based on the trial court’s decision,
but the details of the trial court’s decision belong in Procedural
History.
Yes No
IRAC: You stated the I/issues above already. The author
17. should start by quoting the overall rule/law (usually a code
section, part of the Constitution, or case) and then should apply
it to the parties in our case, reaching a conclusion. Do this for
each issue. Has this been done? Don’t actually type the words
“Rule,” “Application,” “Conclusion.” Just use RAC as your
structure for writing the Reasoning.
Yes No
Has the author explained how the judge decided the case?
Yes No
Comments:
After reading this section, do you feel as if you understand how
the judge decided, or do you feel more confused?
Understand Confused
Explain.
Has the author discussed the legal authorities (cases, statutes,
constitution) and the facts together?
Yes No
Has the author used paragraphs as appropriate? Each issue
should have at least one paragraph devoted to it.
Yes No
Comments:
How might the author improve this section?
Procedural Consequences: (5 points)
Does this section mention the word “affirmed,” or “reversed,”
“modified,” or “remanded”? It should.
Yes No
This section should be only 1 – 2 sentences long. Is it?
Yes No
18. Overall/Miscellaneous:
Has the author used paragraphs as appropriate (for example,
there should be no paragraphs over one page long)?
Yes No
Is the first line of each paragraph indented?
Yes No
Has the author used quotation marks when quoting? You MUST
use quotation marks if quoting. Otherwise it’s plagiarism.
Yes No
Has the author copied and pasted anything from the case? The
answer here should be NO since this is plagiarism.
Yes No
Has the author checked his/her spelling?
Yes No
Has the author used proper grammar?
Yes No
Has the author avoided using contractions or abbreviations?
Yes No
Is the brief double-spaced and typed?
Yes No
Did the author use an 11- or 12-size font?
Yes No
The author should refer to everyone by their last names, not
their first names.
Yes No
Has the author used past tense instead of present tense?
Yes No
Has the author used names rather than party designations
(defendant, plaintiff, appellant, appellee, etc.)
Yes No
Are all case names italicized?
Yes No
Did the author avoid leaving any headings by themselves at the
bottom of the page?
Yes No
For online BUSL 18: Did the author name/save his/her
19. document in the following format: Last name, first name –
brief # __, CRN (5 points – online classes only)
Yes No
Did the author include his/her name on the brief?
Yes No
Is there any other constructive comment you would like to
make?
People v. Simpson (1998) 65 Cal.App.4th 854, 76 Cal.Rptr.2d
851
[No. G020449. Fourth Dist., Div. Three. Jul 24, 1998.]
THE PEOPLE, Plaintiff and Respondent, v. RICHARD
ANDREW SIMPSON, Defendant and Appellant.
(Superior Court of Orange County, No. 95CF1264, David T.
McEachen, Judge.)
(Opinion by Bedsworth, J., with Sills, P. J., and Rylaarsdam, J.,
concurring.)COUNSEL
Arthur H. Weed for Defendant and Appellant.
Daniel E. Lungren, Attorney General, George Williamson, Chief
Assistant Attorney General, Gary W. Schons, Assistant Attorney
General, Keith I. Motley and Janelle Marie Boustany, Deputy
Attorneys General, for Plaintiff and Respondent.OPINION
BEDSWORTH, J.-
A jury found Richard Andrew Simpson guilty of possessing
more than 28.5 grams of marijuana and illegal possession of a
firearm. A prior conviction allegation under Penal Code section
667.5, subdivision (b) was found true by the court.
Prior to trial, an Evidence Code section 402 motion was heard
to determine the admissibility under Miranda v. Arizona (1966)
384 U.S. 436 [86 S.Ct. 1602, 16 L.Ed.2d 694, 10 A.L.R.3d 974]
of statements Simpson made at a police command post
immediately preceding the execution of a search warrant at his
home. The trial court found Simpson's statement revealing the
location of an automatic weapon at his residence admissible
20. under New York v. Quarles (1984) 467 U.S. 649 [104 S.Ct.
2626, 81 L.Ed.2d 550], which articulated a "public safety"
exception to the Miranda rule. (Id. at pp. 655-657 [104 S.Ct. at
pp. 2631-2632].) Simpson appeals from that determination and
also contends the trial court improperly imposed a sentence for
his prior conviction under Penal Code section 667.5,
subdivision (b), because the same conviction was used to prove
he was a convicted felon in connection with the gun possession
charge-a prohibited dual use of facts.
In the published portion of our opinion, we hold that when
police officers prepare to execute a search warrant upon
premises occupied by a known drug trafficker, having probable
cause to believe substantial quantities of illegal drugs will be
found but not knowing who else might be present on the
property, an objectively reasonable basis exists for permitting
them to question the suspect about the presence of weapons and
other potential dangers they might encounter without preceding
such questions with the warnings ordinarily required by
Miranda. In the unpublished part of our opinion, we find the
sentence imposed was legally authorized and not based upon
any impermissible dual use of facts.FACTS
Veteran Culver City Police Officer Mike Conzachi received
information which eventually led a magistrate to issue him
warrants to search four homes, including a residence occupied
by Richard Simpson in Orange Park Acres. Conzachi believed
Simpson and others named in the warrants were in possession of
up to 100 kilos of cocaine and about a half ton of marijuana. He
also knew Simpson had several prior arrests, a state conviction
for selling cocaine, and a federal conviction involving the
importation of approximately 17,000 pounds of marijuana.
Warrant in hand, Conzachi and members of his task force
established a command post at Rancho Santiago College and
began surveillance of Simpson's house. Around 10:15 a.m., Mrs.
Simpson left the residence and drove her child to a nearby
elementary school. Before she could return home, she was
stopped by an Orange County sheriff's deputy and met by
21. Conzachi, who advised her he had a search warrant for her
residence and "was just going to detain her temporarily until
[he] was ready to serve" it. She was then taken to the command
post at the college to wait.
While Mrs. Simpson cooled her heels, a sheriff's deputy
telephoned Simpson and informed him his wife had been in a
traffic accident. He told Simpson she was uninjured but needed
him to meet her and help make arrangements about the car. The
ruse worked: Simpson left the house and was allowed to drive
about five blocks before being pulled over. Officer Conzachi
"just told Mr. Simpson who I was, the reason for his detention,
and that I had a . . . warrant to search his residence because I
suspected . . . he was involved in narcotic trafficking." Simpson
was then placed in handcuffs and taken to the college to join his
wife pending execution of the warrant.
When Conzachi and Simpson reached the college, within five
minutes of the car stop, Conzachi asked "[i]f there were any
guns or weapons on the property." Simpson replied "that he did
have a gun, that it was in his bedroom, [the] upstairs master
bedroom, that it was under a mattress but he did not know
whether . . . it was loaded." He also specifically identified the
weapon as a .380-caliber automatic. In response to further
inquiry, Simpson admitted the gun was his and told Conzachi a
youngster and the child's nanny were still on the premises,
along with 14 Rottweilers-most of which were vicious attack
dogs he expected would not welcome officers arriving to search
the property.
After this brief conversation, Orange County Animal Control
was sent to the scene to secure the Rottweilers, and a search
was conducted without incident. While the officers did not find
the large quantities of drugs they anticipated, they did locate
the automatic weapon and 67.24 grams of marijuana-for which
Simpson was placed under arrest.
At the Evidence Code section 402 hearing conducted before
trial, Conzachi testified that, in his experience, narcotics and
guns are part and parcel of the drug trade, and he recounted
22. occasions upon which he had been drawn into gun battles while
attempting to serve narcotics-related warrants. He explained he
asked Simpson whether guns were in his residence solely to
ensure the safety of his team and any others who might be
present in or around the house when the warrant was served. He
testified, "I realistically can't remember the last time . . . I
encountered, during the service of a search warrant, . . .
evidence of narcotic trafficking or narcotics that there was not a
gun present." Based on this testimony, the court found the
public safety exception to Miranda applied and admitted
Simpson's statement that a .380-caliber automatic was located
under his mattress in the master bedroom.
I
Simpson insists the trial court erred by allowing the prosecution
to introduce his statement about the gun in its case-in-chief
because the statement was not preceded by the warnings and
waivers required by Miranda. We disagree.
Ordinarily, police officers are constrained to precede custodial
interrogation by advising the person to be questioned of the
right to remain silent, the consequences of failing to take
advantage of that right, and the judicially created right to an
attorney, which is financed by the public fisc should the person
lack the ability to pay for the attorney's services. (Miranda v.
Arizona, supra, 384 U.S. at p. 444 [86 S.Ct. at p. 1612].) These
two rights-the right to remain silent and the right to an attorney-
must be waived knowingly and voluntarily before questioning
begins, and the individual queried must indicate an
understanding that any statements made can be used to his or
her detriment in court. (Id. at pp. 478-479 [86 S.Ct. at p. 1630];
accord, People v. Whitson (1998) 17 Cal.4th 229, 244 [70
Cal.Rptr.2d 321, 949 P.2d 18].) When police fail to administer
the prophylactic warnings required by Miranda, any statements
they obtain are inadmissible in the prosecution's case-in-chief
(id. at pp. 492, 494 [86 S.Ct. at pp. 1637, 1638]), although the
statements remain available to impeach the defendant who
testifies inconsistently at trial. (Harris v. New York (1971) 401
23. U.S. 222 [91 S.Ct. 643, 28 L.Ed.2d 1]; Oregon v. Hass (1975)
420 U.S. 714 [95 S.Ct. 1215, 43 L.Ed.2d 570]; accord, People v.
Peevy (1998) 17 Cal.4th 1184 [73 Cal.Rptr.2d 865, 953 P.2d
1212].)
The court that decided Miranda clearly intended its
pronouncements be given sweeping effect, declaring that no
statement obtained without a valid advisement and waiver could
be used against a defendant or exploited for any purpose
inconsistent with a defendant's interests during a criminal trial
anywhere in the United States. (Miranda v. Arizona, supra, 384
U.S. at pp. 444, 476 [86 S.Ct. at pp. 1612, 1629].) But times
have changed dramatically since 1966. (See, e.g., Amar, The
Future of Constitutional Criminal Procedure (1996) 33 Am.
Crim. L.Rev. 1123; Whitebread, The Burger Court's Counter-
Revolution in Criminal Procedure (1985) 24 Washburn L.J. 471-
474.) As a result of the court's own repeated reexamination of
the rule, it has become increasingly clear the scope of the
Miranda rule, like most every other legal principle, has its
limitations.
In Harris v. New York, supra, 401 U.S. 222, and Oregon v.
Hass, supra, 420 U.S. 714, the United States Supreme Court
weighed the benefits of its prophylactic rule against its desire to
discourage defendants from personally proffering perjurious
testimony, and in the end, Miranda gave way. (Cf. United States
v. Havens (1980) 446 U.S. 620 [100 S.Ct. 1912, 64 L.Ed.2d
559]; and Michigan v. Harvey (1990) 494 U.S. 344 [110 S.Ct.
1176, 108 L.Ed.2d 293], where the court similarly deemed the
Fourth Amendment and Sixth Amendment exclusionary rules
less crucial than the need to discourage defendants from
providing perjured testimony.) In Michigan v. Tucker (1974)
417 U.S. 433 [94 S.Ct. 2357, 41 L.Ed.2d 182], the court
considered the scope of the rule and concluded a failure to
properly administer Miranda warnings did not justify the
exclusion of derivative evidence discovered only because the
police had exploited the defendant's unwarned statement. And in
1984, in New York v. Quarles, supra, 467 U.S. 649, the high
24. court refined the meaning of Miranda further by defining a
situation in which the rule would have no application at all.
In Quarles, police officers were approached by a young woman
who told them she had been raped by a man who subsequently
entered a supermarket carrying a gun. (New York v. Quarles,
supra, 467 U.S. at pp. 651-652 [104 S.Ct. at pp. 2628-2629].)
When Quarles was finally apprehended, police found him
wearing a shoulder holster, but the holster was empty and no
gun was on his person. Without administering Miranda
warnings, an officer asked what had become of the gun, and
Quarles responded by nodding in the direction of some cartons,
saying, " '[t]he gun is over there.' " (Id. at p. 652 [104 S.Ct. at
p. 2629].)
[3] The court concluded "that the need for answers to questions
in a situation posing a threat to the public safety outweighs the
need for the prophylactic rule protecting the Fifth Amendment's
privilege against self-incrimination." (New York v. Quarles,
supra, 467 U.S. at p. 657 [104 S.Ct. at p. 2632].) In so holding,
the court expressed its confidence that ". . . police officers can
and will distinguish almost instinctively between questions
necessary to secure their own safety or the safety of the public
and questions designed solely to elicit testimonial evidence
from a suspect." (Id. at pp. 658-659 [104 S.Ct. at p. 2633],
italics added.) Thus, Quarles teaches that where questions are
reasonably directed to defusing a situation which threatens the
safety of either police officers or members of the general
public, a suspect's answers are admissible in evidence, even if
the questions were not preceded by Miranda warnings, and even
if they happened to elicit an incriminating response.
As the court in People v. Gilliard (1987) 189 Cal.App.3d 285
[234 Cal.Rptr. 401] insightfully observed, Quarles was
"detained, frisked, and handcuffed prior to any questioning and
was surrounded by at least four police officers when questioned
about the gun. Nothing in the Quarles opinion suggests the
police were then concerned for their own safety. Moreover,
there was no imminent urgency; the supermarket was almost
25. deserted and presumably could have been cordoned off. (New
York v. Quarles, supra, 467 U.S. at p. 676 [104 S.Ct. at p. 2642]
(dis. opn. of Marshall, J.).) Nor was there any lack of
opportunity for the officers to provide Miranda warnings prior
to any questioning. It was enough, however, that the officers
reasonably believed the gun had been disposed of in a public
place to justify an inquiry as to its location before Miranda
warnings were required. As noted by the Supreme Court, had
the suspect been provided Miranda warnings before such
questions were asked, he might well have been deterred from
responding, leaving a dangerous weapon at large in a public
area." (People v. Gilliard, supra, 189 Cal.App.3d at p. 291.)
[1b] So here, even though Simpson, who was handcuffed at a
police command post, posed no imminent threat to anyone at the
moment he was asked about guns in his residence, and even
though there was no lack of opportunity to read him Miranda
warnings, the public safety exception of New York v. Quarles
still applies if the questions Conzachi asked were primarily
related to an objectively reasonable need to protect police
officers or the public from the dangers that would be
immediately encountered once the police attempted to enter
Simpson's residence to execute their warrant. (New York v.
Quarles, supra, 467 U.S. at p. 659, fn. 8 [104 S.Ct. at p. 2633].)
We find that they were. And the mere fact those questions also
elicited an incriminating response does not remove them from
the ambit of the Quarles exception.
Officer Conzachi, a veteran police officer who has participated
in the service of innumerable narcotics-related search warrants,
testified that the safety of police officers who are required to
execute those warrants is always at serious risk. We are not
surprised. Illegal drugs and guns are a lot like sharks and
remoras. And just as a diver who spots a remora is well-advised
to be on the lookout for sharks, an officer investigating cocaine
and marijuana sales would be foolish not to worry about
weapons. Particularly where large quantities of illegal drugs are
involved, an officer can be certain of the risk that individuals in
26. possession of those drugs, which can be worth hundreds of
thousands and even millions of dollars, may choose to defend
their livelihood with their lives-or, in this case, with the lives of
14 Rottweilers, the Luddite equivalent of a cache of AK-47's.
As the United States Supreme Court has made clear by limiting
the application of its own rule, where human life is in peril, the
purposes underlying Miranda pale by comparison to an officer's
obligation to protect members of the public-and police-from
harm. Thus, invoking the Quarles doctrine, our courts have
permitted an officer to ensure his own safety by asking an in-
custody suspect if he had needles or drug paraphernalia on his
person prior to a search (People v. Cressy, supra, 47
Cal.App.4th 981) and validated an officer's inquiry about the
location of a gun discarded by a suspect leaving the scene of a
shooting (People v. Gilliard, supra, 189 Cal.App.3d 285). The
Quarles "public safety" exception applies with equal force here,
where officers had been commanded by way of a magistrate's
warrant to enter into unknown quarters in which the use of
deadly force was well within the realm of reasonable
probability.
Relying on U.S. v. Mobley (4th Cir. 1994) 40 F.3d 688,
Simpson contends public safety concerns did not justify the
inquiry about guns in his residence, since he had already been
tricked into leaving his home, was being held some distance
away in police custody, and had no access to his weapon. But
Mobley is inapposite. There, by the time an FBI agent asked any
questions of Mobley-who had been stark naked and alone when
an agent entering his apartment pinned him behind his own front
door-other agents had already performed a protective sweep of
the place and assured themselves no one else was present. And
it was a good bet Mobley's birthday suit concealed no weapons.
Thus the court reasoned that when an agent asked whether
Mobley had any weapons in his apartment, any danger such
weapons might have posed had already been neutralized.
Consequently, Miranda waivers should have been solicited
before the question was asked. But that was not the situation
27. here.
A neutral magistrate found probable cause to believe substantial
quantities of illegal drugs were being secreted in Simpson's
residence, and Conzachi's extensive experience in serving
narcotics-related warrants led him to anticipate the presence of
weapons that might be used to protect those drugs from seizure.
Moreover, Conzachi had no way of knowing for sure who might
still be "behind the door" at Simpson's home. The mere fact
Simpson told the officer only a child and a nanny were inside
was certainly not dispositive. Conzachi was not obliged to
believe Simpson and unnecessarily subject himself and others to
dangers he reasonably believed to exist.
The concerns we have discussed with regard to the service of
narcotics-related search warrants are generally known, and they
pose a clear and present danger to the safety of police officers,
suspects, and other members of the general public. That's what
Quarles was meant to protect against, and this is a proper case
for its application.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
The judgment is affirmed.
Sills, P. J., and Rylaarsdam, J., concurred.
On August 21, 1998, the opinion was modified to read as
printed above. Appellant's petition for review by the Supreme
Court was denied November 18, 1998.