beneroth changed the topic of #picolisp to: PicoLisp language | The scalpel of software development | Channel Log: https://libera.irclog.whitequark.org/picolisp | Check www.picolisp.com for more information
peterhil has joined #picolisp
aw- has quit [Ping timeout: 240 seconds]
aw- has joined #picolisp
peterhil has quit [Ping timeout: 252 seconds]
razzy has joined #picolisp
hunar has joined #picolisp
tankf33der has quit [Quit: the lounge - https://webirc.envs.net]
tankf33der has joined #picolisp
beneroth has joined #picolisp
<razzy> Good morning everyone!
<razzy> I have troubles with (task). I think is impossible to debug task as concurrent thing. yes?
<hunar> Good morning razzy :)
<razzy> do I need to give task some time to run code? Simple examples work. complex task parael to infinite loop does not execute.
<Regenaxer> Hi razzy, hunar!
<Regenaxer> A task is normal code, can be debugged
<Regenaxer> eg insert a '!'
<Regenaxer> Note that tasks do *not* run in "parallel"
<Regenaxer> (doc 'task) (doc '*Run)
<Regenaxer> It runs "during key, sync, wait and listen"
<Regenaxer> So if your code is in a loop, it will not run
<Regenaxer> $ man 2 select
<Regenaxer> or better $ man 2 poll
<Regenaxer> This as called "asynchronous I/O"
<razzy> Regenaxer: thank you. I was looking for wait function to test it.
<Regenaxer> yes, wait is one of these
<Regenaxer> Typical applications are started with -wait on the commandline
<Regenaxer> so they drop into (wait)
<Regenaxer> Without wait, they drop into a REPL which will kall (key)
<razzy> Regenaxer: what if i want to give task just enough time to execute and no more?
<razzy> like interrupt would work?
<Regenaxer> I do not understand
<razzy> I want to spend as much time as possible working in my infinite loop.
<razzy> and i want to stop every 2s to do task.
<Regenaxer> yes, so what is the problem?
<Regenaxer> Ah, then you cannot use a task
<Regenaxer> it is never called in an infinite looq
<Regenaxer> loop
<razzy> I can put 30 ms wait for task to execute
<Regenaxer> Your loop must call the code periodically
<razzy> but how do i know if it is enough time
<Regenaxer> You can wait just 1 ms then
<razzy> my loop is not time consistent
<Regenaxer> but this is a bit inefficient
<Regenaxer> sleeping in the loop
<razzy> i do not want to write to SSD 100k writes/ minute
<Regenaxer> But (wait 1) is enough
<Regenaxer> it polls all files and timers, and executes whatever is needed
<Regenaxer> this may take any time
<Regenaxer> if the task expression takes one hour, then you r loop is paused one hour
<razzy> ok, so when task start it also finishes
<Regenaxer> It is all cooperative
<razzy> thank you. you have been most helpfull :]
<Regenaxer> :)
<razzy> btw, i burned my SSD a bit when testing. picolisp is very fast :]
<Regenaxer> oh :(
<Regenaxer> I did not know that you can burn an SSD by writing too fast
<razzy> you can destroy it by rewriting too much
<razzy> picolisp was too fast for me to react :D
<razzy> I was like: oh nice, it is working,... oh no i have already 100k file writes :D
<Regenaxer> I see :)
<beneroth> SD cards are pretty quickly damaged this way
<beneroth> as more then one robot startup discovered. logging unto SD card for long times ;)
<beneroth> SSD should be able to compensate if it has enough free space (free cells to do wear leveling) afaik
<aw-> razzy: when doing any code that writes to files, it's always best to test in a tmpfs first
<Regenaxer> Hi beneroth, aw-!
<aw-> and once you're done then you change the write path to fixed disk
<aw-> hi Regenaxer
<beneroth> aw-, good advice!
<beneroth> hi everyone :)
<aw-> if you make a size=80% tmpfs, and your code messes up then you'll "only" fill RAM up to 80%
<aw-> not enough to take down your system
<beneroth> if firefox is not open xD
<aw-> beneroth: :P
<beneroth> aw-, ;-)
<razzy> aw-: good advice. I will use it :]
<razzy> bbl
razzy has quit [Quit: leaving]
hunar has quit [Ping timeout: 256 seconds]
hunar has joined #picolisp
razzy has joined #picolisp
razzy has quit [Ping timeout: 244 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 252 seconds]
razzy has joined #picolisp
<razzy> hmm, (wait 0) seems to trigger (task) but does not seem to trigger periodically. (wait 1) waste 25% of CPU
<razzy> not a big problem. but I think (wait 0) should be allowed.
<Regenaxer> Well, (wait 0) waits zero milliseconds, so there is no time to wait for anything
<Regenaxer> Why don't you call the code you want to execute directly instead of calling 'wait'?
<razzy> Regenaxer: I looked at script you send. I do not really understand it, but i think it is sending keys to whatever Xwindow. it is good. I do not think script can also read terminal. I want to live in picolisp, i want to read terminal, process in picolisp, make human action, process in picolisp, send to terminal. do you know of good way?
<Regenaxer> yes, sends keys and mouse events to X
<Regenaxer> I use it all day long
<beneroth> razzy, you can do (wait) without count
<Regenaxer> You saw it perhaps in PilCon
<Regenaxer> I send events from my Penti/phone to the desktop
<beneroth> Regenaxer, I believe (wait) is basically the equivalent of C sleep(0); (execute pending threads/processes/tasks, but if nothing is to do continue asap)
<beneroth> roughly speaking
<Regenaxer> To read from the terminal the only way is copy/paste I think, e.g. from tmux
<razzy> Regenaxer: I need part of my code to execute depending on global time. I do not have(know) good way of doing it in my variable infinite loop.
<Regenaxer> beneroth, yes, it is waitFd() in src/io.l
<beneroth> Regenaxer, thx
<Regenaxer> Wall clock time is (time), does this help?
<razzy> Regenaxer: if (wait) is possible, than it solves instantly everything
<Regenaxer> You can (wait (* 1000 (- Time (time))))
<razzy> Regenaxer: so there is no way to read terminal screen and process it in picolisp, yes?
<Regenaxer> There is no way in *Unix*
<Regenaxer> It may be a serial terminal, or remote via ssh
<razzy> weird. pure (wait) does not work.
<razzy> it seems to execute code only partially
<razzy> *execute (task) code
<razzy> Regenaxer: i think i remember function that sends command to linux terminal, maybe return response. i forgot name. do we have something like that in pil21?
<Regenaxer> I think your approach of calling (wait) in a busy loop to let task run is meaningless
<Regenaxer> The timers which *Run maintains count the *idle* times
<Regenaxer> Waiting for multiple events
<Regenaxer> they are *not* real-time measurement devices
<Regenaxer> I do not understand what you want to do with the terminal
<Regenaxer> A terminal is a stream of characters
<Regenaxer> There is no concept of reading it
<Regenaxer> You need to buffer output for that, e.g. read the paste buffer of tmux
<Regenaxer> You can send commands to tmux to read previous lines
<Regenaxer> BUT: What do you want to do with that?
razzy has quit [Ping timeout: 252 seconds]
razzy has joined #picolisp
<razzy> Regenaxer: not-realtime, explains a lot. so alarm was better?
<Regenaxer> I would simply put code *inside* the loop
<Regenaxer> Just check (usec)
<razzy> loop is time variable
<razzy> hmm, might work, thx.
<Regenaxer> Yes, check (usec) frequently
<Regenaxer> it is very fast, a lot faster than (wait)
<Regenaxer> 7.374 sec
<Regenaxer> : (bench (do 9999999 (wait 0)))
<Regenaxer> -> NIL
<Regenaxer> : (bench (do 9999999 (usec)))
<Regenaxer> 1.962 sec
<Regenaxer> -> 50646076
<razzy> do we have function that sends command to linux terminal, maybe return response.in pil21?
<razzy> Regenaxer: I want to command linux terminal from pil REPL
<Regenaxer> As I said, there is no concept of "sending a command to terminal" in Unix
<Regenaxer> You can *emulate* a terminal, like what 'psh' does. See 'ctty'
<Regenaxer> It is also used in the pseudo terminal for PilBox I showed in PilCon
<razzy> hmm,.. that is promissing
<Regenaxer> pil21/bin/pty is a kind of "terminal" then
<beneroth> razzy, maybe you want just a (pipe) ?
<beneroth> or just execute a unix command read result? e.g. (in '(hostname) (line T))
<beneroth> see (call) and the third forms (taking list as first argument) of (in) and (out), and (pipe) which is basically a combination of in/out with list
<razzy> beneroth: (pipe) might actually do.
<razzy> thank you
<Regenaxer> Perfect :)
<Regenaxer> The key to giving good answers is understanding the questions ;)
<razzy> yep, asking good question is part of solution
<razzy> i will explain myself more in future :]
<Regenaxer> I'm sometimes a bit slow to understand
<beneroth> we all are sometimes
razzy has quit [Ping timeout: 245 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 245 seconds]
hunar has quit [Quit: Client closed]
beneroth_ has joined #picolisp
beneroth has quit [Ping timeout: 252 seconds]
razzy has joined #picolisp
razzy has quit [Ping timeout: 245 seconds]
beneroth_ has quit [Remote host closed the connection]
beneroth_ has joined #picolisp
beneroth_ has quit [Client Quit]
beneroth has joined #picolisp
aw- has quit [Quit: Leaving.]
razzy has joined #picolisp
razzy has quit [Ping timeout: 252 seconds]
razzy has joined #picolisp