Programming :: POSIX__Philosophers At Dinner: Error: Initializer Element Is Not Constant
Jun 23, 2010
I changed my post because I found that solution, and didn't want to bother for that. But, since I didnt find a way to delete the post, I thought of updating it: I am beginning to write the code for the philosophers problem. As you know, they can eat, think or wait for forks. When they have 2 forks, one by each side, they eat. Then they set the 2 forks as available, and think.
Each philosopher is a thread. My problem is that it gives segmentation fault, somehow, when I try to initialize. The thing I really don't understand, is why it sometimes gives segmentation fault on initialization #0!!! (But generally on initialization #1) I have set 5 initializations in total, defined by N, that is also the number of threads I'm working on.
I'm implementing exceptions using longjmp() (since C++ exceptions don't offer the features that I need, including resuming and a "finally" block), like this:
I'm trying to make a very small script with greasemonkey to do some automatic things when a page loads. The first thing I need to do is to click on a link. I've done that. Then I need to select the 3rd element of a drop down list that appears a few moments (depending on the connection) after the link is pressed, without reloading the page (ajax or something like that). This I can't get to work, The select has no id or class, but I can get its xpath value. There is only one select on the page. I've tried both setTimeOut and the DOMNodeInserted event with no effect.
So I have been trying for 8 hours to try to get the index of an element from a list in a Makefile. The problem is that after I get the index using all the methods I have tried, the index cant be used in the "word" function:
for instance: $(OUTPUT2) : INDEX = $(shell echo $(OUTPUT2) | sed -r -e "s/[ ]+/ /g" | grep -n $@ | sed 's/^([0-9]*):.*/1/')
will create a variable INDEX defined specifically for each member of OUTPUT2, so that each output knows its index. Unfortunately, when I pass this $(INDEX) into word, it doesn't work:
$(OUTPUT2) : $(word $(INDEX), $(INPUT1)) $(word $(INDEX), $(INPUT2)) echo $(INAME) $(TMPBASE) $@ and I get the error: Makefile:16: *** non-numeric first argument to `word' function: 'num'. Stop.
I feel like if I could just convert a string to a Makefile acceptable number this would just work....
I am using Scientific Linux version 2.6.9-67.EL.cernsmp (root@lxcert-i386) (gcc version 3.4.6 20060404 (Red Hat 3.4.6-9)) #1 SMP Wed Nov 21 16:22:33 CET 2007. Now I want to install rediff bol in it. so i downloaded rediff bol from the site
Code: http://linux.softpedia.com/progDownload/rediffbol-prpl-Download-34762.html after that i have downloaded libpurple and libpurple developement from
I tried to install ubuntu 9.04 from wubi in windows 7 ultimate today. But it failed. I met a problem when installing: An error has occurred setting the element data. The request is not supported. The detailed information in installation log file is:
>>stdout= 01-26 13:29 DEBUG TaskList: # Cancelling tasklist 01-26 13:29 DEBUG TaskList: New task modify_bcd 01-26 13:29 ERROR root: Error executing command >>command=C:WindowsSystem32cdedit.exe /set {d29666c7-0a4d-11df-a945-002268e2b352} device partition=I: >>retval=1 >>stderr=An error has occurred setting the element data.
The request is not supported.
[Code].....
The request is not supported. I tried to use bcdedit /set <GUID> device partition=I: manually, but still have the same error.
it's been a while since I logged on here! I've been trying my hand at a little perl and have hit a brick wall.I'm using the Imagemagick module to manipulate some images. I can get the following to work without issue:
I'm reading "OReilly Learning Perl 5th Edition", and there are such words:Code:You can use an array element like $fred[2] in every place? where you could use any other scalavariable like $fred.At the bottom of the page, it explains the ? like this:Code:The most notable exception is that the control variable of a foreach loop, which you?ll see later in this chapter, must be a simple scalar.Since Perl has the save-and-restore mechanism for the control variable, why an array element can't be used as the control variable
I'm using libxml2 to handle/manipulate some XML files. In order to check the consistency of a XML file, I have a DTD and I'm using the xmlValidateDtd method to compute the check.
However, when an error occures during the check (for example an attribute is missing in a XML tag), then libxml2 writes the error on the stdout/stderr. For exemple:
Code:
/home/XML/FreeFour.xml:18: element CA: validity error : Element CA does not carry attribute maxlength
The method return the right result (true or false depending on the check result), but occurring errors are written on the stdout/stderr, and I actually don't want that.
Can I predefine constant array in c? with constants i do #define NAMEOFCONST value.is it possible to do this for an array? And if not I would like to know why. I suspect it has to do with memory handeling and pointers.
I'm on 10.04. 64bit (but dont think this is 64bit related)
I have been getting this very annoying error while trying to burn DVD-DL media from an iso using growisofs. Here is the command I used (to burn a backup copy of an xbox360 game)
Code: growisofs -use-the-force-luke=dao -use-the-force-luke=break:1913760 -dvd-compat -speed=2.4 -Z /dev/scd0=nameofmyiso.iso Now, every single time, usually around 50%, I get this error:
I've been searching around and found threads with people complaining about this error since 2005, but not a single one of them presented any solution (some hint to a kernel issue, which I'd have no idea how to fix. I'm a noob at linux).
I also tried burning it using imgburn under wine, same error, also at 50%.
This is very frustrating, Ive burned around 6 coasters so far and DVD-DL are expensive to keep on this trial and error.
p.s It's not faulty media before anyone asks. I tried it on Mac and it worked fine. Also, this drive worked well before, before I migrated this machine.
Install SSH2, but he constantly collide error. It is that [pecl install -f ssh2] but unfortunately writes error and can not be installed. Now it is up to the SSH2 provides but unfortunately cancel running.
Here is the php info : [URL] .....
System : Debian 8.1 Jessie
Debian 7.8 : The installation fails without error but that is not enough fresh modules.
Nothing serious (I think), but everytime I run apt-get to remove programs and doing upgrades... I get a strange message.
This is the output of apt-get upgrade: Inspiron1525:/home/hernan# apt-get upgrade Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: iamerican ibritish 0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded. 17 not fully installed or removed. After this operation, 4030kB disk space will be freed .....
And this is the output I get when removing a program (I removed amor so I can show the output): Inspiron1525:/home/hernan# apt-get remove amor Reading package lists... Done Building dependency tree Reading state information... Done
The following packages will be REMOVED: amor iamerican ibritish 0 upgraded, 0 newly installed, 3 to remove and 0 not upgraded. 17 not fully installed or removed. After this operation, 6185kB disk space will be freed. Do you want to continue [Y/n]? y (Reading database ... 89741 files and directories currently installed.) Removing iamerican ... /var/lib/dpkg/info/iamerican.postrm: line 6: /usr/sbin/remove-default-ispell: No such file or directory dpkg: error processing iamerican (--remove): subprocess post-removal script returned error exit status 1 ..... E: Sub-process /usr/bin/dpkg returned an error code (1)
I have installed Ubuntu 10.04 LTS on a flash drive and everytime I try to do an update I get the following error message:
Code: Setting up linux-image-2.6.32-33-generic (2.6.32-33.72) ... Running depmod. update-initramfs: Generating /boot/initrd.img-2.6.32-33-generic lzma: Encoder error: -2147467259 Failed to create initrd image.
[Code]...
also, I would like to know if I want to make clones of the flash drive, would a copy and paste suffice or do i need to use some cloning software? I have followed the instructions on ubuntu wiki to make my casper-rw larger than 4GB by making it an ext4 partition.
I've just updated my linux system (Debian) and went to compile some code I'm working on. However it causes some problems, presumable because of GCC up dates. I get many of my subject line errors for example
../../common/Version_Control.cpp: In function int VersionControl(): ../../common/Version_Control.cpp:55: warning: deprecated conversion from string constant to char*
So I check up the error and it comes from my error handler code which is a function
I have tried to keep away from posting this seeing how many have had the same problem but this is getting to the point of me just selling my computer out of shear frustration. Ive got Windows XP and Ubuntu 10.04lts. For a while they all ran fine together till my Windows drive gave out and ever since I tried to remove the drive GRUB recovery has been popping up. I even tried to put the drive back in and the computer still wont boot anything. Ive got 4 different live boots and neither one works, Ive tried to boot with my internal dvd drive and a usb one, there is always a Grub error. When I put in the ls command and find my only non"unknown filesystem" it still says "bad filename". I guess where im getting at is grub wont even let me reformat my computer or boot from anything without saying "no such device: 32d98-e0b3-451b-809b-ae6562ccb701"
after update to slackware current 4 days ago i cant get sound working in wine in starcraf 2 i mean i got sound in instalation but not in game and i get error when i wanna configure sound in winecfg
err:alsa:ALSA_CheckSetVolume Could not find '{PCM,Line} Playback Volume' element err:alsa:ALSA_CheckSetVolume Could not find '{PCM,Line} Playback Volume' element err:alsa:wine_snd_pcm_recover underrun occurred err:alsa:wine_snd_pcm_recover underrun occurred
in game i dont got that error but sound dont work btw my sound card is asus xonar essence stx
I have a doubt, i have a file which contains around 3000 elements, now i want to search for an element in that file.what will be the Efficient way of searching ? without consuming much memory and time..
1) is this efficient if i take all the 3000 elements from file to a list or array and sort them and search ? 2) or is it efficient to search directly inside the file ?? Can anyone please suggest some algorithms for an efficient way to search in this case ?I am using C for coding..
I want to print, using locate, all the paths that contain the element /bin/ but only one instance of each one. If I issue 'locate /bin/' then I have many screens of text with, for example,
/usr/bin/foo1 /usr/bin/foo2 /home/me/bin/foo3 whereas I want to see only /usr/bin/foo1 /home/bin/foo3
That is to say, if in two lines /bin/ appears with the same prefix (in the example above the prefixes would be /usr and /home/me) I only want to print the first line. Can I pipe locate to grep to do this? I've mentioned locate because it does not scan the whole disk.
Kernel 2.6.21.5, slackware 12.0 For a given app run by me as user john to be able to create a file in /foo1/foo2/, what do I need? (a) john to have write permissions in /foo1/? (b) john to have write permissions in /foo1/foo2/? (c) john to have write permissions in both /foo1/ and /foo1/foo2/? Any hint will be welcome. Note: No. It's not homework. KTorrent complains when trying to create the files being downloaded, saying 'permission denied'. But I think he is being run by another user. I can explain in a different thread.
I have an array ch and I want to increment each element in my array for the following if statement. I'm not sure I have the right array increment syntax but I have tried it in different ways ant it doesn't seem to work.
I tried ch[$1]++, ch[$1]+1, ch[$1++], ch[$1]+=1, ch[$1]=ch[$1]+1 none of these seem to work. # while loop reading from read.txt for check list 1 - 15 for i in `seq 15` do a=`grep "${cl[$i]}" $file` status=$? if [[ $status = 0 ]]; then echo -n -e "1 " let ch[$i+1] let k++ else echo -n -e "0 " fi done for l in `seq 20` do echo -n -e "${ch[$l]} " done