Author Topic: Scriptbasic Build Linux  (Read 62430 times)

Offline John

  • Forum Support / SB Dev
  • Posts: 3510
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #180 on: January 22, 2019, 11:24:33 PM »
I tried removing the MAIN loop and changed sb_msSleep to 1.


jrs@jrs-laptop:~/sb/examples/test$ scriba sbt_main.sb
T-1 : 1
T-1 : 2
T-2 : 1
T-1 : 3
T-2 : 2
T-1 : 4
T-2 : 3
T-1 : 5
T-2 : 4
T-1 : 6
T-2 : 5
T-1 : 7
T-1 : 8
T-2 : 6
T-2 : 7
T-1 : 9
T-1 : 10
T-2 : 8
T-2 : 9
T-2 : 10
T-3 : 1
T-3 : 2
T-3 : 3
T-3 : 4
T-3 : 5
T-3 : 6
T-3 : 7
T-3 : 8
T-3 : 9
T-3 : 10
jrs@jrs-laptop:~/sb/examples/test$


Mike Lobanovsky

  • Guest
Re: Scriptbasic Build Linux
« Reply #181 on: January 23, 2019, 01:27:44 AM »
For an interpreter, the theoretically ultimate shortest sleep period will be determined by how complicated and slow (or simple and fast) the interpreter implementation is regarding its read/write access to a memory location defined in the BASIC code.

To speed things up still further, you may try and exclude sb_msSleep() periods altogether. As per the script, each worker thread increments and prints its own X variable so there are no cross-thread read/write access conflicts possible in this setup.

OTOH if each of the threads were to increment, and print the current value of, a global shared variable, then their respective accesses to it in the PRINT statement should be enclosed in Lock/UnlockWrite calls to prevent another thread's possible concurrent incrementation of the shared variable that would cause a memory access violation (segfault). Similarly, a write access to the shared variable to increment it should prevent concurrent reads by framing the incrementation code with Lock/UnlockRead. I think the sleep periods could then be safely omitted as well. But this is only my supposition that needs further investigation.

A few microseconds to make a couple interpretative calls to Lock/Unlock would still be much faster than the 1000 microseconds that usleep(1) defines.

[UPD] Unlike MS Windows Sleep(1), the Linuxoid usleep(1) defines a 1-microsecond, not 1-millisecond, time lapse... :o
« Last Edit: January 23, 2019, 07:37:55 PM by Mike Lobanovsky »

Offline John

  • Forum Support / SB Dev
  • Posts: 3510
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #182 on: January 23, 2019, 09:24:49 AM »
I need to look at sbhttpd a little closer to see how Peter dealt with this issue. At least BASIC threads is working on multiple platforms.

Each thread is it's own instance of SB that can have it's own set of extension modules. That is what makes this so cool.
« Last Edit: January 23, 2019, 09:44:56 AM by John »

Mike Lobanovsky

  • Guest
Re: Scriptbasic Build Linux
« Reply #183 on: January 23, 2019, 07:49:38 PM »
I've just learnt that usleep() specifies time lapses in microseconds rather than milliseconds (times 1000 microseconds).

I'm afraid it makes usleep-dependent code non-portable to Windows as-is unless linked against the POSIX Threads for Windows library (which goes under LGPL)... ::)

Offline John

  • Forum Support / SB Dev
  • Posts: 3510
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #184 on: January 24, 2019, 04:02:55 PM »
I think using MT and assigning a priority, a well managed multi-threaded environment could be achieved. BASIC programmers would have to design their code with a sharing frame of mind.

1 - Run until thread competes
2 - Share CPU with other SB threads
3 - Only run if no other SB threads are active
« Last Edit: January 24, 2019, 04:07:24 PM by John »

Mike Lobanovsky

  • Guest
Re: Scriptbasic Build Linux
« Reply #185 on: January 24, 2019, 06:07:00 PM »
I think virtually all modern BASIC translators and JIT or static compilers that are equipped with their own machine code generators (VB.NET, PowerBASIC, FBSL, OxygenBasic) or use 3rd party asm or C compiler back ends (FreeBASIC, BCX and clones) are suitable for successful multithreaded code generation.

Which means that there should already be a sufficient BASIC user base who are aware of that facility and are using it in their creative work in accordance with their main objectives.

Offline John

  • Forum Support / SB Dev
  • Posts: 3510
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #186 on: January 24, 2019, 09:34:16 PM »
Mike,

Would you be willing to put together an example how SB theads can be used other than a FOR/NEXT loop in unison? The SB Inno Windows install has SBT included.

Maybe this would make a good code challenge. AIR, what do you think?
« Last Edit: January 24, 2019, 10:07:08 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 3510
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #187 on: May 20, 2019, 02:57:54 PM »
AIR,

Would it be difficult to add creating a bin/mod/obj/(new ext. mod) directory if a ./setup --module=(new ext. mod) is done for the first time?
« Last Edit: May 20, 2019, 02:59:52 PM by John »

Offline AIR

  • BASIC Developer
  • Posts: 932
  • Coder
Re: Scriptbasic Build Linux
« Reply #188 on: May 20, 2019, 03:55:23 PM »
If you have run the full setup first, then yes.

The reason being that the full setup run generates header files that are needed by modules (like basext.h).  That's why the source tree in git consists mainly of .c files; the headers are generated by the setup script.  An advantage of this approach is that you only need to edit .c files if you want to add something to the core, unless you're introducing a new keyword, in which case you need to modify a couple of other files.  But no header files.

Anyway, so if you already have executed setup by itself, you can then do ./setup --module=testing, for example.

That's the first step I use when creating a new module.  Then I generally nuke everything except the interface.c file.  If you configure that correctly (read the comments in the generated interface.c file) you don't have to mess around with headers, include files (meaning .bas files with the exported functions), the .jim/.jam files, or "make" files since they are all auto-generated for you by the setup script.

Also, as you've seen in a couple of the modules I've built, you can provide .c/.h source files for code you're trying to wrap (slre is an example) and they will be parsed and compiled along with your own module code into the final module library. 


AIR.

Offline John

  • Forum Support / SB Dev
  • Posts: 3510
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #189 on: May 20, 2019, 05:28:26 PM »
The only issue with creating a new extension module after running the initial setup is the  bin/mod/obj directory for it needs to be created first. After that, it compiles fine.

No problem, I can continue using this method if I don't want to start over with a fresh build.

Thanks for the  build details!

Offline AIR

  • BASIC Developer
  • Posts: 932
  • Coder
Re: Scriptbasic Build Linux
« Reply #190 on: May 21, 2019, 04:26:48 PM »
I don't have that issue, the required structure is created for me.

Offline John

  • Forum Support / SB Dev
  • Posts: 3510
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #191 on: May 21, 2019, 04:49:21 PM »
For me everything gets created properly except the directory in obj. Using SB-dev-cleanup.

Offline John

  • Forum Support / SB Dev
  • Posts: 3510
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #192 on: June 16, 2019, 09:56:57 AM »
AIR,

If someone wants to build SB but not install MySQL for example, will mkdeb.sh still create an install. deb?

Quote
Hmmm....There is no libssl1.0.0 in Debian stretch. I have the libssl1.0.2 installed.

Hmmm... There is no libmysqlclient20 in Debian stretch. Which I don't want anyway.
« Last Edit: June 16, 2019, 10:00:10 AM by John »

Offline AIR

  • BASIC Developer
  • Posts: 932
  • Coder
Re: Scriptbasic Build Linux
« Reply #193 on: June 16, 2019, 10:59:47 AM »
Try the "mkdist.sh" file, passing it the path to place SB in.

Code: [Select]
./mkdist ~/sb
Then you have the option of configuring SB (adding the bin folder to your path, and setting up the conf file) or you can do what I do, and use the sb.sh script located in the destination folder.


You can either source the sb.sh file and have everything set for that terminal session, OR run the sb.sh file (from within the DESTINATION sb folder itself) passing it the script to run.

I've updated the repo.  A "git pull" will bring down the updated files.


AIR.


Offline John

  • Forum Support / SB Dev
  • Posts: 3510
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #194 on: June 16, 2019, 01:39:53 PM »
Heater finally got SB running. It looks like sb.sh isn't getting included with your mkdist.sh script.

You have given users multiple options on how to install and use ScriptBasic. I need to create documentation that anyone can understand.