Skip to: Site menu | Main content


Welcome to PSP-Programming.com, a place for developers to get together.

Welcome to the forums. Here you can find other user tutorials as well as homebrew releases and the source code repository. You can also ask for help with your code here and post your own homebrew!

PSP-Programming.com Forums
February 10, 2012, 01:21:20 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

News: Check out the Code Section!
Home Help Search Shop Login Register
Digg This!
Pages: [1]
Print
Author Topic: PLZ help  (Read 1193 times)
litva
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 20
278.68 points

View Inventory
Send Money to litva

View Profile
« on: March 14, 2010, 03:34:47 AM »

Hi all.guys, i has had a problem with my code.i am trying to start a new thread.
Code:
error = pthread_create(&tid[0],
                           NULL,
                           pull_one_url,
                           (void*)urls[0]);
but the game is frozen with bus error or without error .what'is it?i am out of my ideas.
it's need me to work with internet how in standart browser.image draw and other pictures write in buffer from site.
Logged


AlphaDingDong
Combat Muskrat
All-Around Dev
Hero Member
*

Karma: +32/-3
Offline Offline

Posts: 882
2044.69 points

View Inventory
Send Money to AlphaDingDong
Hey... Are you gonna eat that?


View Profile
« Reply #1 on: March 15, 2010, 03:26:41 AM »

The PSP doesn't use pthreads.  It has its own threading lib (which is pretty similar).

Check here:
http://psp.jim.sh/pspsdk-doc/group__ThreadMan.html

And also search the site for thread examples.
Logged
litva
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 20
278.68 points

View Inventory
Send Money to litva

View Profile
« Reply #2 on: March 15, 2010, 06:15:24 AM »

/*
   pthread library for the PSP
   Copyright (C) 2006  Rafael Cabezas a.k.a. Raf

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2
   of the License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
very strange.thank for advise.now i am going to use sceKernelCreateThread."initPriority    The initial priority of the thread. Less if higher priority"what is it ?what does  thread start early.
Logged
Raphael
Global Moderator
Hero Member
*

Karma: +230/-10
Offline Offline

Posts: 1431
193700.11 points

View Inventory
Send Money to Raphael


View Profile WWW
« Reply #3 on: March 16, 2010, 01:50:56 AM »

There is no "start early" on PSP, because the threading is coop, not pre-emtive. The question is when do you give your threads time to process, through a sleep/delay in your main thread.

Other than that, it's as is stated, a lower value denotes a higher priority, with 0 the highest. You shouldn't really use anything above priority 12 or 10.
Logged

Don't push the river, it flows.
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki
http://www.homebrew-illuminati.co.uk - serious homebrew development for all platforms
Alexander Berl
"A good mod is a combination playground monitor, priest, big brother/sister, psychiatrist, professor and more."
litva
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 20
278.68 points

View Inventory
Send Money to litva

View Profile
« Reply #4 on: March 17, 2010, 09:28:33 AM »

on no thid = sceKernelCreateThread("my_thread",(SceKernelThreadEntry)pull_one_url ,10, 0x10000, 0, 0);
            if(thid >= 0)
            {
               sceKernelStartThread(thid, sizeof(urls[0]), (void*)urls[0]);
            }
return bus error.
« Last Edit: March 17, 2010, 09:58:03 AM by litva » Logged
AlphaDingDong
Combat Muskrat
All-Around Dev
Hero Member
*

Karma: +32/-3
Offline Offline

Posts: 882
2044.69 points

View Inventory
Send Money to AlphaDingDong
Hey... Are you gonna eat that?


View Profile
« Reply #5 on: March 17, 2010, 08:28:28 PM »

Adapted from a sample I found somewhere a long time ago.  I just compiled it and ran it without incident:

Code:
#include <pspkernel.h>
#include <pspctrl.h>
#include <pspdebug.h>
#include <pspdisplay.h>

PSP_MODULE_INFO("PSP Threading", 0, 1, 1);

int running = 1;

int threadFunction(SceSize argsize, void* arg) { //thread functions must prototype to "int func(Scesize, void*)"
  while(running) {
    pspDebugScreenPrintf("This is the thread talking.\n");
    sceKernelDelayThread(1); //a sceKernelDelayThread yields time to other threads
  }
  sceKernelExitDeleteThread(0); //thread exits and deletes itself
  return 0;
}

int main() {
  pspDebugScreenInit();
  SceCtrlData pad;
 
  int thid = sceKernelCreateThread("Talking Thread", threadFunction, 0x10, 0x1000, 0, NULL); //get thread handle - args are ("arbitrary process name", entry point function, thread priority, stack size, attribute flags, SceKernelThreadOptParam*)
  sceKernelStartThread(thid, 0, NULL); //start the thread - args 2 and 3 are passed into the thread function
 
  while(running) {
    sceCtrlPeekBufferPositive(&pad, 1);
    if(pad.Buttons & PSP_CTRL_CROSS) {running = 0;}
    pspDebugScreenPrintf("This is the main thread talking.\n");
    sceKernelDelayThread(1);
  }
  sceKernelDelayThread(3000000); //pause for a moment so you can see the result
  sceKernelExitGame();
  return 0;
}
Logged
litva
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 20
278.68 points

View Inventory
Send Money to litva

View Profile
« Reply #6 on: March 19, 2010, 08:24:01 AM »

My program stops when there is a start of a new thread, but your example is compiled and starts  well
« Last Edit: March 20, 2010, 03:37:23 AM by litva » Logged
AlphaDingDong
Combat Muskrat
All-Around Dev
Hero Member
*

Karma: +32/-3
Offline Offline

Posts: 882
2044.69 points

View Inventory
Send Money to AlphaDingDong
Hey... Are you gonna eat that?


View Profile
« Reply #7 on: March 19, 2010, 07:24:47 PM »

 Shocked

What?
Logged
litva
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 20
278.68 points

View Inventory
Send Money to litva

View Profile
« Reply #8 on: March 25, 2010, 04:59:18 AM »

my program is frozen when thread starts!!!
« Last Edit: March 25, 2010, 05:01:00 AM by litva » Logged
Raphael
Global Moderator
Hero Member
*

Karma: +230/-10
Offline Offline

Posts: 1431
193700.11 points

View Inventory
Send Money to Raphael


View Profile WWW
« Reply #9 on: March 25, 2010, 07:00:59 AM »

can't answer why, without showing us the exact code.
Logged

Don't push the river, it flows.
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki
http://www.homebrew-illuminati.co.uk - serious homebrew development for all platforms
Alexander Berl
"A good mod is a combination playground monitor, priest, big brother/sister, psychiatrist, professor and more."
litva
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 20
278.68 points

View Inventory
Send Money to litva

View Profile
« Reply #10 on: March 25, 2010, 09:29:33 AM »

static int pull_one_url(char *url)
   {
   curl = curl_easy_init();

      
      curl_easy_setopt(curl, CURLOPT_URL, url);
      

      curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writer);

      //указываем куда записывать принимаемые данные
      curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
      curl_easy_perform(curl);

      return 1;
   }
   int threadFunction(SceSize argsize, void* arg){
      pull_one_url(urls[0]);
      sceKernelExitDeleteThread(0);
      return 1;
   }
...
thid1 = sceKernelCreateThread("Talking Thread", threadFunction, 0x05, 0x1000, 0, 0);
sceKernelStartThread(thid1, 0, NULL);
...
Logged
Raphael
Global Moderator
Hero Member
*

Karma: +230/-10
Offline Offline

Posts: 1431
193700.11 points

View Inventory
Send Money to Raphael


View Profile WWW
« Reply #11 on: March 25, 2010, 10:16:54 AM »

1. use code tags when posting code

   int threadFunction(SceSize argsize, void* arg){
      pull_one_url(urls[0]);
      sceKernelExitDeleteThread(0);
      return 1;
   }
2. Where/how is the urls array declared?
3. Why do you start a thread, that in turn just calls a single function and returns? Since the function itself is blocking and the psp has a coop threading model, you actually gain nothing from starting it in a thread, other than possibly delaying the function call a little bit, depending on what you main thread does after creating this thread.
Quote
thid1 = sceKernelCreateThread("Talking Thread", threadFunction, 0x05, 0x1000, 0, 0);
0x5 is pretty high priority and shouldn't be used unless you know what you do. Start with something like 0x18 and slowly decrease it, if you feel the thread isn't "responsive" enough.
Logged

Don't push the river, it flows.
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki
http://www.homebrew-illuminati.co.uk - serious homebrew development for all platforms
Alexander Berl
"A good mod is a combination playground monitor, priest, big brother/sister, psychiatrist, professor and more."
litva
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 20
278.68 points

View Inventory
Send Money to litva

View Profile
« Reply #12 on: March 26, 2010, 04:50:36 AM »

Code:
const char * const urls[4]= {
 "http://ourgame.orgfree.com/store/",
 "ftp://cool.haxx.se/",
 "http://www.contactor.se/",
 "www.haxx.se"
};
thread starts and returns bus error,This function stops thread and waits while the page is loading .
« Last Edit: March 27, 2010, 11:33:12 PM by litva » Logged
Pages: [1]
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.591 seconds with 35 queries.
Sister Sites: Guitar Hero 4   BrokeniTouch.com