Login
Username:

Password:

Remember me



Lost Password?

Register now!
Main Menu
Who's Online
16 user(s) are online (11 user(s) are browsing Forum)

Members: 3
Guests: 13

slicer, hardwaregeek, phoenixkonsole, more...

Browsing this Thread:   1 Anonymous Users



« 1 (2) 3 »


Re: Nano VM - testers/developers wanted

Joined:
2011/9/25 1:23
From Hungary
Group:
Member
Posts: 1306
Offline
I tried the above code but it didn't quite solve problem. One of the arguments of LockMutex is still NULL, it could be ThreadBase too.
One thing I noticed is that you don't use pthread_join/WaitThread in your code. Instead you do busy loops until the given thread sets its state. I'm mentioning this, because one of the functions which overflows the stack is wait_thread_running().

edit: LockMutex fails in exe_elist(), because cclist_mutex is not itialized for AROS in main.c, hence the NULL pointer.

edit #2: Ignore my previous post about the stack increasing wrapper, it's unnecessary. Initializing cclist_mutex solves the problem. Here are the two thread-waiting functions without the busy loop:

void wait_thread_running (S4 threadnum)
{
    
LockMutex (pthreads_mutex);
    if (
pthreads[threadnum].thread)
        
WaitThread(pthreads[threadnum].threadNULL);
    
UnlockMutex (pthreads_mutex);
}

void join_threads (S4 threadnum)
{
    
/* wait until all threads are stopped */
    
S4 i;
    
    
LockMutex (pthreads_mutex);
    
/* thread zero is the main thread, don't wait for it!!! */
    
for (1MAXPTHREADSi++)
    {
        
/* don't check the calling thread!!! */
        
if (!= threadnum && pthreads[i].thread)
        {
            
WaitThread(pthreads[i].threadNULL);
        }
    }
    
UnlockMutex (pthreads_mutex);
}


Replacing WaitThread with pthread_join would work on other platforms. Checking (pthreads[i].state == PTHREAD_RUNNING) isn't necessary anymore, since these thread waiting functions instantly return on terminated threads.

Posted on: 2013/1/7 5:39

Edited by BSzili on 2013/1/7 6:03:13
_________________
My AROS&MorphOS ports
Arguments that explain everything... explain nothing.
Transfer the post to other applications Transfer


Re: Nano VM - testers/developers wanted

Joined:
2010/1/1 6:14
Group:
Member
Posts: 40
Offline
Thanks for your help!

Now I found out what the error for not running the sort-test program was: I just messed up the "bytecode" while running the program in the VM. So the new code for the VM pointer instruction works now really.

I compiled a version for Aros with my new code: it runs now
the sort-test program without errors.

I will add your code tomorrow into my actual version.

Well here are my nano VM version 3.0.27 binaries attached.

Attach file:


gz nano-aros.tar.gz Size: 320.00 KB; Hits: 38

Posted on: 2013/1/7 12:17
Transfer the post to other applications Transfer


Re: Nano VM - testers/developers wanted

Joined:
2011/9/25 1:23
From Hungary
Group:
Member
Posts: 1306
Offline
Great! Have you added the socket stuff too? I'd like to try the nano web server on AROS.

Posted on: 2013/1/8 0:23
_________________
My AROS&MorphOS ports
Arguments that explain everything... explain nothing.
Transfer the post to other applications Transfer


Re: Nano VM - testers/developers wanted

Joined:
2010/1/1 6:14
Group:
Member
Posts: 40
Offline
I didn't touch the wait_thread_running () code:
It waits till the new thread is running. So it's not a wait for the thread end.

And I didn't check the socket stuff. I have still to do this.
I don't know if it works.

The new source code is on my homepage. (www.jay-t.de).



Posted on: 2013/1/8 10:32
Transfer the post to other applications Transfer


Re: Nano VM - testers/developers wanted

Joined:
2011/9/25 1:23
From Hungary
Group:
Member
Posts: 1306
Offline
Is there a difference between waiting while the thread is running, and waiting for the thread to exit?

Posted on: 2013/1/8 11:46
_________________
My AROS&MorphOS ports
Arguments that explain everything... explain nothing.
Transfer the post to other applications Transfer


Re: Nano VM - testers/developers wanted

Joined:
2010/1/1 6:14
Group:
Member
Posts: 40
Offline
It's waiting till the thread is started (was created).
It's the thread_sync function in the examples.
This is for synchronizing threads.
The next step would be sendig data to the thread:
with threadpush ().

It should be a hello_thread.nc demo in the base archive on my homepage.

I tried the webserver program: it exits with an error message:
socket error: 2.

What is that errorcode saying?

Posted on: 2013/1/9 5:01
Transfer the post to other applications Transfer


Re: Nano VM - testers/developers wanted

Joined:
2011/9/25 1:23
From Hungary
Group:
Member
Posts: 1306
Offline
Oops, then I misunderstood the purpose of the function The error number says nothing to me, you should use strerror(). Have you applied all the bsdsocket-related changes?
edit: Also make sure that to open bsdsocket.library in the same thread where you do the socket operations, because you can't share socket descriptors between threads. Technically it's possible to pass sds between threads, but it requires some extra code, and generally not worth the hassle if you can move all the socket manipulation into one thread.

Posted on: 2013/1/9 7:20

Edited by BSzili on 2013/1/9 8:19:35
_________________
My AROS&MorphOS ports
Arguments that explain everything... explain nothing.
Transfer the post to other applications Transfer


Re: Nano VM - testers/developers wanted

Joined:
2010/1/1 6:14
Group:
Member
Posts: 40
Offline
I just putted SocketBase into the pthreads structure:
And the threadnum is used by the socket open calls (server / client).


S2 init_arossock (S4 threadnum)
{
pthreads[threadnum].SocketBase = (struct Library *) OpenLibrary ("bsdsocket.library", 0);
if (pthreads[threadnum].SocketBase == NULL)
{
return (FALSE);
}

if (SocketBaseTags (SBTM_SETVAL (SBTC_ERRNOPTR (sizeof (errno))), (IPTR) &errno, SBTM_SETVAL (SBTC_HERRNOLONGPTR), (IPTR) &h_errno, TAG_DONE ))
{
return (FALSE);
}
return (TRUE);
}


So the init_arossock is called when pthreads[].socket_lib_open is false.

I don't know if this is a good idea.
Is this "legal" to do?

But now I get a illegal instruction error while running the webserver program.

I had to put a struct Library *SocketBase = NULL; into the VM main_d.h or it couldn't be compiled cause of the declaration in the aros includes.





Posted on: 2013/1/10 13:04
Transfer the post to other applications Transfer


Re: Nano VM - testers/developers wanted

Joined:
2011/9/25 1:23
From Hungary
Group:
Member
Posts: 1306
Offline
You are on the right path, but the implementation is not quite there. Every bsdsocket.library call takes SocketBase as an argument, and since you declared a global NULL SocketBase socket functions will fail. To solve the problem, you can include this header instead of proto/bsdsocket.h, and use SocketBase as normal, which will become the taks's user defined field. Please note that you have to do call init_arossock() in the right thread, preferably in a wrapper around exec_list, and don't declare a global SocketBase variable.

Posted on: 2013/1/10 13:51
_________________
My AROS&MorphOS ports
Arguments that explain everything... explain nothing.
Transfer the post to other applications Transfer


Re: Nano VM - testers/developers wanted

Joined:
2010/1/1 6:14
Group:
Member
Posts: 40
Offline
I did update my sourcecodes: the last version can be downloaded via subversion on sourceforge (3.0.29-4):
some bugfixes to the compiler, and other AROS changes on the code.

You can take a look at it, if the socket stuff is done right.
IMHO it still doesn't work right. Maybe I didn't made it right.

I tested it and I still got error messages.

Posted on: 2013/1/26 11:29
Transfer the post to other applications Transfer



« 1 (2) 3 »



You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.

[Advanced Search]


Search
Top Posters
1 paolone
paolone
3636
2 nikolaos
nikolaos
3451
3 phoenixkonsole
phoenixkonsole
2978
4 magorium
magorium
2866
5 deadwood
deadwood
2315
6 mazze
mazze
2058
7 clusteruk
clusteruk
2052
8 ncafferkey
ncafferkey
2047
9 damocles
damocles
1788
10 Kalamatee
Kalamatee
1711
© 2004-2013 AROS Exec