Theadmin77
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
- intitemCount
- procedureproducer(){
- while(true){
- item=produceItem()
- if(itemCount==BUFFER_SIZE){
- sleep()
- }
- putItemIntoBuffer(item)
- itemCount=itemCount+1
- if(itemCount==1){
- wakeup(consumer)
- }
- }
- }
- procedureconsumer(){
- while(true){
- if(itemCount==0){
- sleep()
- }
- item=removeItemFromBuffer()
- itemCount=itemCount-1
- if(itemCount==BUFFER_SIZE-1){
- wakeup(producer)
- }
- consumeItem(item)
- }
- }
Oct 30 '07 #1
Subscribe Reply
4 2150
gpraghuram 1,275 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 + 1if (itemCount == 1) {
wakeup(consumer )
}
}
}procedure consumer() {
while (true) {if (itemCount == 0) {
sleep()
}item = removeItemFromB uffer()
itemCount = itemCount - 1if (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 New Member
No unfortunately my code does not compile .
Oct 31 '07 #3
reply
sicarie 4,677 Recognized Expert Moderator Specialist
So what errors are you getting?
Oct 31 '07 #4
reply
Ganon11 3,652 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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets 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 projectplanning, coding, testing, and deploymentwithout 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 |