473,322 Members | 1,241 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

deadlocked code

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. int itemCount
  2.  
  3. procedure producer() {
  4.     while (true) {
  5.         item = produceItem()
  6.  
  7.         if (itemCount == BUFFER_SIZE) {
  8.             sleep()
  9.         }
  10.  
  11.         putItemIntoBuffer(item)
  12.         itemCount = itemCount + 1
  13.  
  14.         if (itemCount == 1) {
  15.             wakeup(consumer)
  16.         }
  17.     }
  18. }
  19.  
  20. procedure consumer() {
  21.     while (true) {
  22.  
  23.         if (itemCount == 0) {
  24.             sleep()
  25.         }
  26.  
  27.         item = removeItemFromBuffer()
  28.         itemCount = itemCount - 1
  29.  
  30.         if (itemCount == BUFFER_SIZE - 1) {
  31.             wakeup(producer)
  32.         }
  33.  
  34.         consumeItem(item)
  35.     }
  36. }
Oct 30 '07 #1
4 2134
gpraghuram
1,275 Expert 1GB
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()
}

putItemIntoBuffer(item)
itemCount = itemCount + 1

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

procedure consumer() {
while (true) {

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

item = removeItemFromBuffer()
itemCount = itemCount - 1

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

consumeItem(item)
}
}

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
No unfortunately my code does not compile .
Oct 31 '07 #3
sicarie
4,677 Expert Mod 4TB
So what errors are you getting?
Oct 31 '07 #4
Ganon11
3,652 Expert 2GB
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

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

Similar topics

51
by: Mudge | last post by:
Please, someone, tell me why OO in PHP is better than procedural.
9
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...
4
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
16
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} ;
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...
1
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...
2
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: ...
6
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,...
18
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.