Login
Username:

Password:

Remember me



Lost Password?

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

Members: 0
Guests: 17

more...

Browsing this Thread:   1 Anonymous Users



(1) 2 3 »


Nano VM - testers/developers wanted

Joined:
2010/1/1 6:14
Group:
Member
Posts: 40
Offline
First of all I want to thanks all people here who helped me
to get the threading working.

Nano VM runs now on AROS, with some trouble:
Locking/Unlocking mutex doesn't work right (thread.library).

Nano is a virtual machine. The "bytecode" can be generated by
the N compiler or the assembler.

N is a new language written for the VM.
Currently the other OS it runs on are Linux and Windows.

More info on my homepage:

http://www.jay-t.de/nano/index.html

And on my community site:
http://diy-2010.net/community/2012/03/03/nano-virtual-machine

I'm searching some developers who want to help to make the port fully working.

The VM is on the download page (version 3.0.26).

Posted on: 2013/1/1 14:27

Edited by jay-t-77 on 2013/1/1 16:15:06
Transfer the post to other applications Transfer


Re: Nano VM - testers/developers wanted

Joined:
2011/9/25 1:23
From Hungary
Group:
Member
Posts: 1316
Offline
Can you describe the symptoms of the mutexes "not working right"? They have no effect, or crash?

Posted on: 2013/1/2 1:31
_________________
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 get:

Software Failure
----------------
Program Failed
Task: 0x02533B90 - thread library thread
Error 0x8000010B unknown CPU error

I attached the pthread.c sourcecode, I think something must be wrong there.

The init_pthreads() function is called on VM startup.

The other functions are called from the VM execution part while running.


Attach file:


c pthread.c Size: 6.32 KB; Hits: 84

Posted on: 2013/1/2 2:08
Transfer the post to other applications Transfer


Re: Nano VM - testers/developers wanted

Joined:
2011/9/25 1:23
From Hungary
Group:
Member
Posts: 1316
Offline
The name of the task indicated that the crash is happening inside one of the threads. Can you give me a nano program, which produces this error? I have an older AROS version compiled with debug-enabled, maybe I can get a backtrace.

edit: A quick glance through the source revealed that you don't include prot/thread.h everywhere, where you use any thread.library functions. Also instead of extern-ing SocketBase, it's better to include proto/bsdsocket.h. Also don't forget, that you can't close() or ioctl() a socket on AROS. You have to use CloseSocket() and IoctlSocket().

Posted on: 2013/1/2 3:15
_________________
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
Well prot/thread.h is included in global_d.h the standard include in every *.c file.

So it's everywhere included.

For the CloseSocket() calls I have to make some changes.

You asked for a Nano program. It's attached.
To run it simply start it in a shell:

$ nanovm sort-test

This should throw the error message.

Edit:
If you compile nano with debugging messages on, you can see
the commands that are executed.

You have to set DEBUG to 1 in include/host.h.

And call like this:

$ nanovm sort-test -d

Attach file:


gz nanovm-testprog.tar.gz Size: 10.00 KB; Hits: 38

Posted on: 2013/1/2 4:44

Edited by jay-t-77 on 2013/1/2 5:16: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: 1316
Offline
Oops I missed that it's already in global_d.h.
Don't forget to use SocketBaseTags after you open bsdsocket.library to set the errno ptr. If you don't do that the errno variable will only hold DOS errors, but not socket ones. There's an example here:
http://en.wikibooks.org/wiki/Aros/Dev ... /Docs/Libraries/BSDsocket

I'll test the sorting program soon.

edit: I tried the VM, and I got this error:
Quote:
[KRN] Task thread.library thread went out of stack limits
[KRN] Lower a950ee90, upper a96030d0, SP a9501c10


Unfortunately thread.library doesn't give you any means to control the stack size when it creates a process. You have to start a wrapper function with CreateThread() which increases the stack size before calling exe_elist(). You can use my header as a base to do that.


Posted on: 2013/1/2 5:45

Edited by BSzili on 2013/1/2 6:43:53
Edited by BSzili on 2013/1/2 6:46:02
Edited by BSzili on 2013/1/2 6:47:27
_________________
My AROS&MorphOS ports
Arguments that explain everything... explain nothing.
Transfer the post to other applications Transfer


Re: Nano VM - testers/developers wanted

Joined:
2006/7/29 4:11
Group:
Member
Posts: 3005
Offline
@jay-t
could you point me to a original c source from one of your N examples? I am curios if i could get used to "convert" c to N.

Posted on: 2013/1/2 7:55
_________________
http://www.vesalia.de/e_aresone2011.htm
www.aresone.de
www.aros-broadway.de still WIP
www.ares-shop.de the ground for our app-store
Transfer the post to other applications Transfer


Re: Nano VM - testers/developers wanted

Joined:
2010/1/1 6:14
Group:
Member
Posts: 40
Offline
@BSzili I used your patch include file and a stack size of 100000. Unlucky I did get the same error message again.
I don't know what happend.


@phoenixkonsole The examples are in N: *.nc files or assembly: *.na files. There are no C sources of the examples.

The compiler outputs assembly code (*.na).
I did this to make debugging of the compiler easier.
So it's "readable" assembly code.

At the assembler there are 256 integer, 256 double and 256 string registers. IMO that is a lot.

Do you want to make a C to N convertor?

Well N is a lot simpler to parse than C.
As I started the only thing I had was the assembler.
And writing assembly code isn't funny when programs get larger.

Then I thought about hacking a C compiler backend to output Nano assembly. But this was to complicated to do.

As a last choice I started from scratch and designed N my own language.

N has some drawbacks:
You can not write nested function calls and the if statement
allows only one BOOL variable.

Math expressions are evaluated from left to right:

i = x + y * z;

Will calculate in this order. There is no * before + rule there.

On the other side N allows multiple return arguments.
See the povcol example.

It uses returnmulti (red, green, blue, ret);
to return the color values.

Or the sort-test program shows how to use the sort library function to sort number arrays. The sort function checks the argument type of the number and calls the right subroutine to sort the array. In C this would be function overloading.

And the dynamic data type can store qint, double and string in the same array. Some kind of structured storage.

With the N inline assembly, assembly code can be wrapped in N functions. This is needed sometimes.

I wanted to keep things simple but still being useful.

Posted on: 2013/1/2 13:41
Transfer the post to other applications Transfer


Re: Nano VM - testers/developers wanted

Joined:
2011/9/25 1:23
From Hungary
Group:
Member
Posts: 1316
Offline
You misunderstood me. By including the header without modification,
all you did was increasing the size of the main thread. You have to
increase the stack of the child threads (processes) created by thread.library.
To archieve that, you have to start threads like this:

int exe_elist_trampoline (int threadnum)

    
struct Task *mytask FindTask(NULL); 
    
ULONG stacksize = (UBYTE *)mytask->tc_SPUpper - (UBYTE *)mytask->tc_SPLower
    
int rc FALSE;

    if (
stacksize >= (ULONG)arosthread_stack)
    { 
        
rc exe_elist(threadnum); 
    } 
    else
    { 
        
struct StackSwapArgs swapargs;
        
struct StackSwapStruct stack;
        
        
swapargs.Args[0] = threadnum;
        
        if ((
stack.stk_Lower AllocVec(arosthread_stackMEMF_PUBLIC)))
        {
            
stack.stk_Upper = (void *)((int)stack.stk_Lower arosthread_stack);
            
stack.stk_Pointer stack.stk_Upper;
            
            
rc NewStackSwap(&stack, (void *)exe_elist, &swapargs);
            
            
FreeVec(stack.stk_Lower);
        }
        else
        {
            
printf ("Couldn't allocate %d bytes for stack.n"arosthread_stack);
        }
    }
 
    return 
rc


(...)

CreateThread (exe_elist_trampoline, (void *) threadnum);

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


Re: Nano VM - testers/developers wanted

Joined:
2011/9/25 1:23
From Hungary
Group:
Member
Posts: 1316
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.

Posted on: 2013/1/7 3:38

Edited by BSzili on 2013/1/7 4:24:48
_________________
My AROS&MorphOS ports
Arguments that explain everything... explain nothing.
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
3639
2 nikolaos
nikolaos
3452
3 phoenixkonsole
phoenixkonsole
3005
4 magorium
magorium
2909
5 deadwood
deadwood
2324
6 mazze
mazze
2065
7 clusteruk
clusteruk
2050
8 ncafferkey
ncafferkey
2046
9 damocles
damocles
1769
10 Kalamatee
Kalamatee
1705
© 2004-2014 AROS Exec