 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
daaa57150
Joined: 17 Nov 2006 Posts: 28
|
Posted: Tue Jun 17, 2008 8:01 pm Post subject: semaphores |
|
|
Hi,
I have searched a lot about this and I thought I've found the proper way to have a mutex but it seems it's not the case, my PSP freezes. can please someone tell me if I do this correctly:
I have an object that will handle a thread internally let's call it ObjWithThread. This ObjWithThread contains a std::list that needs to be protected with a mutex, as the thread it launches modifies it.
So, I made this ObjWithThread have a semaphore member m_semaid like this:
| Code: | | m_semaid = sceKernelCreateSema("OWTSema", 0, 1, 1, 0); |
and 2 functions to lock/unlock the object, that I call before/after reading from the list from outside the ObjWithThread:
| Code: | void ObjWithThread::lock()
{
sceKernelWaitSema(m_semaid, 1, 0);
}
void ObjWithThread::unlock()
{
sceKernelSignalSema(m_semaid, 1);
} |
the inner thread is created like this:
| Code: | | m_threadId = sceKernelCreateThread("OWTThread", OWTfunction, 0x11, 0xFA0, PSP_THREAD_ATTR_USER|PSP_THREAD_ATTR_VFPU, NULL); |
and launched like this:
| Code: | | sceKernelStartThread(owt->m_threadId, sizeof(owt), &owt); //owt is a pointer to the ObjectWithThread itself |
and before the thread tries to write to the list, I call the lock function, and after the writing is finished, I call the unlock function and sceKernelDelayThread(500) because it's in an infinite loop:
| Code: | void ObjWithThread::OWTfunction(SceSize args, void *argp)
{
ObjWithThread *_this = *((ObjWithThread**) argp);
while(true)
{
_this->lock();
//here I modify the std::list
_this->unlock();
sceKernelDelayThread(500);
}
} |
what is wrong in there? The PSP freezes if I try to access the std::list from outside the ObjWithThread, and works correctly if I don't touch it. This means the list is not protected with the mutex, and I can't figure out why!
Help... |
|
| Back to top |
|
 |
daaa57150
Joined: 17 Nov 2006 Posts: 28
|
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Thu Jun 19, 2008 3:44 am Post subject: |
|
|
First, we already knew how the use semaphores - you'll find examples all over this forum. That's why no one answered your thread - you hadn't bothered to search, so we didn't bother to answer.
Second, QJ.net sucks. Post count is the almighty factor in how you're treated, and the idiots who do nothing but post inane "me too" posts to increase their count run the forum. I rarely went over there before, and after an incident a couple days ago, I'm never going back and encourage everyone else to avoid that forum as well.
Just as an idea of how stupid they are over at QJ.net - someone recently took an OLD copy of the REALLY OLD 0.5 version of PSPDoom, repacked it with eLoader, and had QJ.net put it out as a "brand new" 3.xx version of Doom. Never mind the fact that PSPDoom was updated for 3.xx more than six months ago. Never mind the fact that my own version of Doom was released about six months ago. It's new! It keeps noobies coming to the site! They don't even allow comments on releases, so you can't warn people to avoid stuff like that. There were almost 3000 downloads of it in a few days by people who were going to be VERY disappointed. That describes how I feel about QJ.net in general - VERY disappointed. |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Thu Jun 19, 2008 4:31 am Post subject: |
|
|
That sucks J.F. :( _________________
Upgrade your PSP |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Thu Jun 19, 2008 8:16 am Post subject: |
|
|
| They've got a big database of homebrew... that's about the only plus they have - as long as you watch out for repackaged garbage like I mentioned above. |
|
| Back to top |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Thu Jun 19, 2008 5:38 pm Post subject: |
|
|
| Thats because the blog is managed by different people who don't know anything about the PSP, not the forum mods/staff. |
|
| Back to top |
|
 |
daaa57150
Joined: 17 Nov 2006 Posts: 28
|
Posted: Thu Jun 19, 2008 6:10 pm Post subject: |
|
|
| J.F. wrote: | | First, we already knew how the use semaphores - you'll find examples all over this forum. That's why no one answered your thread - you hadn't bothered to search, so we didn't bother to answer. |
The fact is, I have bothered to search, I found how to use semaphores here on ps2dev, but my PSP was still freezing, and at the time of writing I didn't know why.
If you had bothered to help me, like they did on QJ, you might have spotted that the problem was a stack problem, and just saying "your semaphore use is correct" would have spare me a bunch of time. But I'm glad you know how to use semaphores yourself.
| J.F. wrote: | | Second, QJ.net sucks. Post count is the almighty factor in how you're treated, and the idiots who do nothing but post inane "me too" posts to increase their count run the forum. I rarely went over there before, and after an incident a couple days ago, I'm never going back and encourage everyone else to avoid that forum as well. |
I encourage people to search for help at QJ, there are a lot more chances to get an answer there. Sure, the quality in the answers is usually a lot lower than here at ps2dev, but usually here 1 of 2 subject I make don't get an answer at all.
| J.F. wrote: | | Just as an idea of how stupid they are over at QJ.net - someone recently took an OLD copy of the REALLY OLD 0.5 version of PSPDoom, repacked it with eLoader, and had QJ.net put it out as a "brand new" 3.xx version of Doom. Never mind the fact that PSPDoom was updated for 3.xx more than six months ago. Never mind the fact that my own version of Doom was released about six months ago. It's new! It keeps noobies coming to the site! They don't even allow comments on releases, so you can't warn people to avoid stuff like that. There were almost 3000 downloads of it in a few days by people who were going to be VERY disappointed. That describes how I feel about QJ.net in general - VERY disappointed. |
Well, there are stupid people at QJ, especially the newsers but there are also nice and skilled people that want to help on the forum. |
|
| Back to top |
|
 |
jean

Joined: 05 Jan 2008 Posts: 489
|
Posted: Thu Jun 19, 2008 6:23 pm Post subject: |
|
|
| We all know that people over here are often rough (to say it nice), J.F. in the first line. But you have to notice that the greatest part of active developers on ps2dev are professionals, and most of them are REALLY sick with children playing to "the greatest hacker". That's why Tyranid always asks what one is trying to do before answering to a question, i guess. I don't give a shit about QJ.net, and if you like it, then use it. Similarly, if you don't like ps2dev then don't use it. We can't spend our entire life teaching to dummies how to code an "hello world". |
|
| Back to top |
|
 |
daaa57150
Joined: 17 Nov 2006 Posts: 28
|
Posted: Thu Jun 19, 2008 6:40 pm Post subject: |
|
|
| jean wrote: | | We all know that people over here are often rough (to say it nice), J.F. in the first line. But you have to notice that the greatest part of active developers on ps2dev are professionals, and most of them are REALLY sick with children playing to "the greatest hacker". That's why Tyranid always asks what one is trying to do before answering to a question, i guess. I don't give a shit about QJ.net, and if you like it, then use it. Similarly, if you don't like ps2dev then don't use it. We can't spend our entire life teaching to dummies how to code an "hello world". | I like ps2dev because as you said, many people here are professional and when I get a answer other than "use the search button" and the likes, it usually is really helpful. And also I can get past answers like I received just here, I know my post was legitimate. And I like QJ because I know I will almost always get an answer, even if the chance of getting a professional answer is (a lot) thinner. That's why I post on ps2dev when I think my problem is difficult, and then if I don't get an answer I put it on QJ. And this time, well, QJ was better, yes it happens. And I'm not coding a Hello World by the way (but you know that). |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Fri Jun 20, 2008 2:21 am Post subject: |
|
|
| daaa57150 wrote: |
If you had bothered to help me, like they did on QJ, you might have spotted that the problem was a stack problem |
Oh yes, because the little snippets you posted in the opening post would have allowed anyone to see that. :headdesk:
Lord save us from noobies who can't tell a bad semaphore from a stack overflow!! Well, you claim to have learned how to search - now you just need to learn how to debug! |
|
| Back to top |
|
 |
daaa57150
Joined: 17 Nov 2006 Posts: 28
|
Posted: Fri Jun 20, 2008 5:30 am Post subject: |
|
|
| J.F. wrote: | | Oh yes, because the little snippets you posted in the opening post would have allowed anyone to see that. :headdesk: |
I don't think so but noone asked me more details. Noone said it couldn't be because of the semaphores. with some discussion things go forward you know.
| J.F. wrote: | | Lord save us from noobies who can't tell a bad semaphore from a stack overflow!! Well, you claim to have learned how to search - now you just need to learn how to debug! | Yes I agree I need to learn to better debug that sort of things. And I made a progress thanks to Insert_Witty_Name on QJ who gave me some good advice. Certainly things that many people here on ps2dev know, but don't bother teach the others.
I don't know why you have this attitude really. You like being self sufficient and mean to those who want to learn? I think it's really the opposite of what I thought this site was all about. Seriously, I were a mod here I would just warn you. |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Fri Jun 20, 2008 5:38 am Post subject: |
|
|
lol if a mod warns someone for don't telling the others what to do I guess everybody will leave this forum. _________________
Upgrade your PSP |
|
| Back to top |
|
 |
daaa57150
Joined: 17 Nov 2006 Posts: 28
|
Posted: Fri Jun 20, 2008 5:46 am Post subject: |
|
|
| Pirata Nervo wrote: | | lol if a mod warns someone for don't telling the others what to do I guess everybody will leave this forum. | That's not what I meant, I meant for that attitude of being so scornful. |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Fri Jun 20, 2008 6:36 am Post subject: |
|
|
Sorry, but we get in that kind of mood when people ask about simple things that developers should already know... like how to debug. We aren't here to hold people's hands. There are plenty of other sites that specialize in beginner programming. When you come here, you should already be proficient at programming. We cut folks slack when they do things like read the old threads and search before asking, otherwise, we cut something else. ;)
And if you think I'm bad, you haven't been here long. I just tend to be condescending. If you want to see some REAL abuse, go check out the Hall of Shame. :) |
|
| Back to top |
|
 |
daaa57150
Joined: 17 Nov 2006 Posts: 28
|
Posted: Fri Jun 20, 2008 5:01 pm Post subject: |
|
|
| J.F. wrote: | | Sorry, but we get in that kind of mood when people ask about simple things that developers should already know... like how to debug. We aren't here to hold people's hands. |
You are not here to help? ok good to know, just don't bash freely on people that are sometimes a little bit more noobish than you, not everyone is excelling magnificiently everywhere like you.
| J.F. wrote: | | There are plenty of other sites that specialize in beginner programming. When you come here, you should already be proficient at programming. |
I did not think that was a beginner problem I had, and I'm proficient in many aspects of programming if there is a slight hypothetic chance that you want to know.
| J.F. wrote: | | We cut folks slack when they do things like read the old threads and search before asking, otherwise, we cut something else. ;) |
What makes you think I haven't? I have done it and as you should have understood now (you are so great so I'm sure you have), I made it correctly, the problem was somewhere else.
| J.F. wrote: | | And if you think I'm bad, you haven't been here long. I just tend to be condescending. If you want to see some REAL abuse, go check out the Hall of Shame. :) | Maybe I will, but not beeing as bad as others don't makes you a good person. But I'm warned now, thank you. |
|
| Back to top |
|
 |
Cpasjuste
Joined: 29 May 2005 Posts: 214
|
Posted: Fri Jun 20, 2008 5:42 pm Post subject: |
|
|
| With all your unusefull comment's JF the ps2dev psp forum are almost like qj.net forum now ... sorry for this but it's not the first time i think you are a bit aggresive. If you hav'nt replied to this thread, it would be done. |
|
| Back to top |
|
 |
jean

Joined: 05 Jan 2008 Posts: 489
|
Posted: Fri Jun 20, 2008 6:49 pm Post subject: |
|
|
| Pleeeeeeeeeeeeeeease stop it! We all know that an half of JF's posts are querelles, but i have to admit that he's right at least a third of the times...i undertand him because to know the things i know today, i'm studing (more or less) for 20 years; so seeing people claiming they're proficient in programming while they demonstrate they know NOTHING is a little frustrating. Moreover, seeing people being unkind because experts HAVE to help others make me really sick! We don't _have_ to do NOTHING! And if we encourage children copying code sunday mornings, we'll se the scene DIE SHORTLY!!!! People around here should know everything about computer programming and should ask only PSP related questions as a guideline. Then if someone uses the forum to kindly chat about nerd's topics it's not an issue for me as long as i don't find evey day two or three posts on "Installing toolchain" or "converting numbers to strings, PLEASE HELP!!!". Life is so difficult, sometimes.............. |
|
| Back to top |
|
 |
daaa57150
Joined: 17 Nov 2006 Posts: 28
|
Posted: Fri Jun 20, 2008 7:56 pm Post subject: |
|
|
Sorry to continue this but I feel quite insulted without a proper reason so I wont run dragging my tail behind me in shame.
| jean wrote: | | to know the things i know today, i'm studing (more or less) for 20 years; so seeing people claiming they're proficient in programming while they demonstrate they know NOTHING is a little frustrating. | I'm studying / working in programming for 8 years so I don't think I know nothing, and I don't think I demonstrated that.
| jean wrote: | | Moreover, seeing people being unkind because experts HAVE to help others make me really sick! We don't _have_ to do NOTHING! | I wasn't unkind, or at least not intentionally (I'm sorry if I did, I'm not a native english speaker so sometimes I don't choose my words correctly). I don't think experts HAVE to help me: I asked, nobody answered, I found answers somewhere else, gave a link for those interested and then got an aggressive answer. If someone is unkind here, that's not me.
| jean wrote: | | And if we encourage children copying code sunday mornings, we'll se the scene DIE SHORTLY!!!! |
Keeping the knowledge between yourselves too, because once you skilled people will loose interest in the PSP, the scene will be dead. I think I was somewhere in the middle, asking to go further.
| jean wrote: | | People around here should know everything about computer programming and should ask only PSP related questions as a guideline. Then if someone uses the forum to kindly chat about nerd's topics it's not an issue for me as long as i don't find evey day two or three posts on "Installing toolchain" or "converting numbers to strings, PLEASE HELP!!!".. | Clearly, semaphores and thread problems are at the same level than number to string conversion. I think I have still a long way to go then.. |
|
| Back to top |
|
 |
hlide
Joined: 10 Sep 2006 Posts: 750
|
Posted: Fri Jun 20, 2008 10:08 pm Post subject: |
|
|
daaa57150, it's okay. You just happen to fall here the wrong moment (Ne0h episode, noobish questions, psptoolchain install trouble, etc.).
Last edited by hlide on Sat Jun 21, 2008 1:13 am; edited 1 time in total |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Fri Jun 20, 2008 11:10 pm Post subject: |
|
|
Close this thread >.< _________________
Upgrade your PSP |
|
| Back to top |
|
 |
daaa57150
Joined: 17 Nov 2006 Posts: 28
|
Posted: Fri Jun 20, 2008 11:12 pm Post subject: |
|
|
| hlide wrote: | | daaa57150, it's okay. It just happens you fall here the wrong moment (Ne0h episode, noobish questions, psptoolchain install trouble, etc.). | Ok, I understand. _________________ Mega Drops
Mega A**hole Portable
Last edited by daaa57150 on Sat Jun 21, 2008 5:16 pm; edited 3 times in total |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
|
| Back to top |
|
 |
jean

Joined: 05 Jan 2008 Posts: 489
|
Posted: Sat Jun 21, 2008 7:20 pm Post subject: |
|
|
| Quote: | | daaa57150, it's okay. You just happen to fall here the wrong moment (Ne0h episode, noobish questions, psptoolchain install trouble, etc.). |
Yes...he's right. Never thougt semaphores and parallelization problems are on the same level of string formatting, and the post was not aimed only at you (or at least it wasn't a reply to your question). I just take position when you incentive others to go on other forums because this isn't noob-friendly...nothing personal |
|
| Back to top |
|
 |
daaa57150
Joined: 17 Nov 2006 Posts: 28
|
Posted: Mon Jun 23, 2008 5:33 pm Post subject: |
|
|
| jean wrote: | | Yes...he's right. Never thougt semaphores and parallelization problems are on the same level of string formatting, and the post was not aimed only at you (or at least it wasn't a reply to your question). I just take position when you incentive others to go on other forums because this isn't noob-friendly...nothing personal | Ok no big deal then, and I'm sorry about the incitement. But hey, if a bunch of noobs follow my advice and go somewhere else, it's a good thing isn't it :) ? _________________ Mega Drops
Mega A**hole Portable |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|