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 |
1 8371 The easy way to turn off automatic updates for Windows 10/11 by: Hystou |last post by: Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,... Windows Server |
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 |
5580 Couldnt get equations in html when convert word .docx file to html file in C#. by: conductexam |last post by: I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();... C# / C Sharp |
4095 Trying to create a lan-to-lan vpn between two differents networks by: TSSRALBI |last post by: Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls... Networking - Hardware / Configuration |
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 |