deadlocked code | Bytes (2024)

Theadmin77

deadlocked code | Bytes (1) 19 New Member

For some reason i am unable to compile or execute the following code ...look like a i have a deadlock or something like that ...

Could anyone send me into the right direction ? Thanks !!
This is the code:

Expand|Select|Wrap|Line Numbers

  1. intitemCount
  2. procedureproducer(){
  3. while(true){
  4. item=produceItem()
  5. if(itemCount==BUFFER_SIZE){
  6. sleep()
  7. }
  8. putItemIntoBuffer(item)
  9. itemCount=itemCount+1
  10. if(itemCount==1){
  11. wakeup(consumer)
  12. }
  13. }
  14. }
  15. procedureconsumer(){
  16. while(true){
  17. if(itemCount==0){
  18. sleep()
  19. }
  20. item=removeItemFromBuffer()
  21. itemCount=itemCount-1
  22. if(itemCount==BUFFER_SIZE-1){
  23. wakeup(producer)
  24. }
  25. consumeItem(item)
  26. }
  27. }

Oct 30 '07 #1

Subscribe Reply

4 deadlocked code | Bytes (2) 2150 deadlocked code | Bytes (3)

gpraghuram

1,275 deadlocked code | Bytes (5) Recognized Expert Top Contributor

For some reason i am unable to compile or execute the following code ...look like a i have a deadlock or something like that ...

Could anyone send me into the right direction ? Thanks !!
This is the code:

int itemCount

procedure producer() {
while (true) {
item = produceItem()

if (itemCount == BUFFER_SIZE) {
sleep()
}

putItemIntoBuff er(item)
itemCount = itemCount + 1

if (itemCount == 1) {
wakeup(consumer )
}
}
}

procedure consumer() {
while (true) {

if (itemCount == 0) {
sleep()
}

item = removeItemFromB uffer()
itemCount = itemCount - 1

if (itemCount == BUFFER_SIZE - 1) {
wakeup(producer )
}

consumeItem(ite m)
}
}

Please use code tqags while posting ur code.
U wint get a deadlock problem when compiling ur code.
Why there are no semi colons(;) in the code.
First tell me, whether ur code is compiling?

Raghuram

Oct 31 '07 #2

reply

Theadmin77

19 deadlocked code | Bytes (6) New Member

No unfortunately my code does not compile .

Oct 31 '07 #3

reply

sicarie

4,677 deadlocked code | Bytes (8) Recognized Expert Moderator Specialist

So what errors are you getting?

Oct 31 '07 #4

reply

Ganon11

3,652 deadlocked code | Bytes (10) Recognized Expert Specialist

Is this even C or C++? If it is, then you are missing semicolons everywhere. If not, then this is the wrong forum for this post.

Oct 31 '07 #5

reply

Sign in to post your reply or Sign up for a free account.

Similar topics

51 5252

OO in PHP

by: Mudge |last post by:

Please, someone, tell me why OO in PHP is better than procedural.

PHP

9 3858

FrontController Design Pattern and Code Reuse

by: bigoxygen |last post by:

Hi. I'm using a 3 tier FrontController Design for my web application right now. The problem is that I'm finding to have to duplicate a lot of code for similar functions; for example, listing users, and listing assignments use similar type commands. Is there a "better" way I can organize my code?

PHP

4 2426

somewhat painful join code

by: jason |last post by:

Hello. Newbie on SQL and suffering through this. I have two tables created as such: drop table table1; go drop table table2; go

Microsoft SQL Server

16 3099

Strange behaviour of simple code

by: Dario de Judicibus |last post by:

I'm getting crazy. Look at this code: #include <string.h> #include <stdio.h> #include <iostream.h> using namespace std ; char ini_code = {0xFF, 0xFE} ; char line_sep = {0x20, 0x28} ;

C / C++

1 2374

ExecuteXmlReader deadlocked exception; new to framework 1.1

by: Adam Smith |last post by:

When executing ExecuteXmlReader() against a table where records are being inserted, I get: 9/5/2003 8:39:47 AM Transaction (Process ID 66) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at System.Data.SqlClient.SqlCommand.ExecuteXmlReader()

C# / C Sharp

1 1672

aspnet_wp.exe (PID: 1864) was recycled because it was suspected to be in a deadlocked state. It did not send any responses for pending requests in the last 180 seconds.

by: bmmodi |last post by:

Hello, We have three webservers that host the same web application (written in VB.NET running on .NET Framework 1.0 SP2). We receive the following error (aspnet_wp.exe (PID: 1864) was recycled because it was suspected to be in a deadlocked state. It did not send any responses for pending requests in the last 180 seconds.) every few days on ONLY ONE of the three servers. At the point when the error occurs, the CPU locks up at 100%. ...

ASP.NET

2 2829

aspnet_wp.exe in a deadlocked state

by: Antonio Concepcion |last post by:

Hi! We have an ASP.NET web site experiencing errors saying that aspnet_wp.exe got into a deadlock state and was recycled. Specifically the Client browser gets the following message: ***************************** Server Application Unavailable The web application you are attempting to access on this web server is currently

ASP.NET

6 1445

Dumping the state of a deadlocked process

by: andre.naess |last post by:

Hi all I'm currently having some issues with a process getting deadlocked. The problem is that the only way I can seem to find information about where it deadlocks is by making a wild guess, insert a pdb.set_trace() before this point, and then step until it locks up, hoping that I've guessed right. The frustrating part is that most of the time my guesses are wrong.

Python

18 6841

multiple threads writing to WebBrowser, getting deadlocked

by: Zytan |last post by:

I have multiple threads writing to WebBrowser (using a function that checks InvokedRequired, and if so, invokes itself on the WebBrowser thread) and they are getting deadlocked. They only deadlock when I use lock { } around the call to WebBrowser.Write to ensure thread safety! Does any one have experience with such a thing? Zytan

C# / C Sharp

8276

What is ONU?

by: marktang |last post by:

ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...

General

8210

Changing the language in Windows 10

by: Hystou |last post by:

Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...

Windows Server

8715

Problem With Comparison Operator <=> in G++

by: Oralloy |last post by:

Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...

C / C++

8646

Maximizing Business Potential: The Nexus of Website Design and Digital Marketing

by: jinu1996 |last post by:

In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...

Online Marketing

8517

Discussion: How does Zigbee compare with other wireless protocols in smart home applications?

by: tracyyun |last post by:

Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...

General

7212

AI Job Threat for Devs

by: agi2029 |last post by:

Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...

Career Advice

4211

Windows Forms - .Net 8.0

by: adsilva |last post by:

A Windows Forms form does not have the event Unload, like VB6. What one acts like?

Visual Basic .NET

1 1819

How to add payments to a PHP MySQL app.

by: muto222 |last post by:

How can i add a mobile payment intergratation into php mysql website.

PHP

2 1523

Comprehensive Guide to Website Development in Toronto: Expert Insights from BSMN Consultancy

by: bsmnconsultancy |last post by:

In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

General

deadlocked code | Bytes (2024)

References

Top Articles
Latest Posts
Article information

Author: Eusebia Nader

Last Updated:

Views: 5880

Rating: 5 / 5 (60 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Eusebia Nader

Birthday: 1994-11-11

Address: Apt. 721 977 Ebert Meadows, Jereville, GA 73618-6603

Phone: +2316203969400

Job: International Farming Consultant

Hobby: Reading, Photography, Shooting, Singing, Magic, Kayaking, Mushroom hunting

Introduction: My name is Eusebia Nader, I am a encouraging, brainy, lively, nice, famous, healthy, clever person who loves writing and wants to share my knowledge and understanding with you.