Recent

Author Topic: Simple multithreading code example in Free Pascal  (Read 24618 times)

LV

  • Jr. Member
  • **
  • Posts: 75
Re: Simple multithreading code example in Free Pascal
« Reply #45 on: August 19, 2024, 09:49:43 pm »
@MarkMLl. Great tips! I'll give it a shot. Thanks a lot!

Joanna

  • Hero Member
  • *****
  • Posts: 1091
Re: Simple multithreading code example in Free Pascal
« Reply #46 on: August 20, 2024, 09:48:02 am »
Quote
Necroposting is generally discouraged,
Markml thanks for teaching me a new word, I thought it was only called forum sliding....
It was nice of LV to revive a 2 year old thread to do a survey  :D
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

Dzandaa

  • Sr. Member
  • ****
  • Posts: 354
  • From C# to Lazarus
Re: Simple multithreading code example in Free Pascal
« Reply #47 on: August 20, 2024, 01:16:29 pm »
Hi,

@ Joanna:

I use 4 threads in Kaleidoscope fun:

https://forum.lazarus.freepascal.org/index.php/topic,68162.msg526171.html#msg526171

Have a look.

B->
Regards,
Dzandaa

MarkMLl

  • Hero Member
  • *****
  • Posts: 7683
Re: Simple multithreading code example in Free Pascal
« Reply #48 on: September 17, 2024, 08:31:05 pm »
@LV you might find it worth looking at Vector Pascal

http://vectorpascalcom.sourceforge.net/

which broadly speaking tries to match APL conceptually and has broad support for parallel hardware.

I notice that a new version was uploaded a few months ago, which should solve the "library rot" it was experiencing when I last looked.

I've explored borrowing ideas from APL in the past (for no particular reason). For example, by writing a reduce function for FPC: define "reduce" as a rubbish type, and then overlay the maths operators with this on the LHS and an array on the RHS allowing

Code: [Select]
<array rank n-1> := reduce + <array rank n>

Predating generics, that needed a lot of boilerplate which could possibly now be avoided. However it came to a juddering halt when I needed to find out something about the rank of the operand... I forget the exact detail but IIRC Sven told me that I was basically up against the foundation concepts of the implementation.

Updated: older thread https://forum.lazarus.freepascal.org/index.php/topic,50024.msg364441.html#msg364441

MarkMLl
« Last Edit: September 17, 2024, 08:39:57 pm by MarkMLl »
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

LV

  • Jr. Member
  • **
  • Posts: 75
Re: Simple multithreading code example in Free Pascal
« Reply #49 on: September 18, 2024, 04:39:00 pm »
@MarkMLl. Thanks for the advice! The Vector Pascal sounds like an interesting topic, I'll check it out. I am grateful for your assistance. LV

gidesa

  • Full Member
  • ***
  • Posts: 116
Re: Simple multithreading code example in Free Pascal
« Reply #50 on: September 18, 2024, 05:30:22 pm »
@LV you might find it worth looking at Vector Pascal

http://vectorpascalcom.sourceforge.net/

Vector Pascal is written in ... Java!!  :(

MarkMLl

  • Hero Member
  • *****
  • Posts: 7683
Re: Simple multithreading code example in Free Pascal
« Reply #51 on: September 18, 2024, 06:10:58 pm »
Vector Pascal is written in ... Java!!  :(

Yes, but the author is a (fairly well-known) CS lecturer, and he's doing it from the POV of having an ALGOL-style language which is capable of handling the same type of problems that APL was (reputedly ** ) good at.

In the first part of the manual he explains why he (and his colleagues/students) chose to extend Pascal (rather than a C-style language or Java), and allowing that by now it's a mature project I think we have to allow him a fair amount of slack (a few years later he'd have added stuff to Perl 6 *** , and these days he'd use Python... so let us be thankful).

There's also a few insights in there: for example, a for statement can be vectorised/parallelised so /of/ /course/ the control variable has no defined value on completion.

I don't have a "real" project to exercise it, but I think it would be interesting to code something using VP's reduction operator, dot product and so on, and then investigate the extent to which FPC could be massaged to do the same. The important thing is that languages such as APL (and for that matter PROLOG etc.) provided a notation style that practitioners in various fields were happy with for 30 years or so, and from my POV the more closely a general-purpose language can replicate that style (without the kitchen sink overflowing with syntactic sugar) the better.

** Provided that you don't look too closely at how much memory was used, and ignored the risk of even the biggest machines thrashing. However a significant amount of this was offset in higher-end implementations, which were smart enough to be able to "reason" about certain structures of array and manipulate their description rather than their (potentially-large) content.

*** https://web.archive.org/web/20201112030222/www.dlugosz.com/Perl6/web/APL.html

MarkMLl
« Last Edit: September 18, 2024, 10:34:40 pm by MarkMLl »
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018