Go to advanced search

by jahboater
Tue Jun 18, 2019 3:41 pm
Forum: Advanced users
Topic: Programming using registers with C
Replies: 6
Views: 138

Re: Programming using registers with C

Hello, I am trying to adapt a C project about Elliptic Curve Diffie-Helmen key exchange, which uses registers, and when I tried to compile it, it says "there's no such registers name" My Q is what are the registers I can use in Raspberry Pi 3 B (BCM2835) to temporarily store processed data instead ...
by jahboater
Mon Jun 17, 2019 9:40 pm
Forum: C/C++
Topic: how to use pthread_kill(pthread_t tid, int sig) by which sig ?
Replies: 19
Views: 401

Re: how to use pthread_kill(pthread_t tid, int sig) by which sig ?

Yes, I had a bad feeling it would do that.
You probably should try a different signal (such as SIGTERM), catch it in the thread, and get the thread to terminate itself.
by jahboater
Sun Jun 16, 2019 10:12 pm
Forum: General discussion
Topic: raspberry pi 3B underclock
Replies: 15
Views: 498

Re: raspberry pi 3B underclock

The pi is in a box. Time to let it out! This is my Pi3B+. The first program run starting at 23:05:01 was one core flat out. As you can see the temp barely rises. The second job starting at 23:05:41 was a deliberate pathological stress test that uses NEON on all four cores. Given time the temp will ...
by jahboater
Sun Jun 16, 2019 6:24 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1110
Views: 27535

Re: ScriptBasic

You will always need root privs to install things on Linux? I hope so anyway. No you don't. I have a lot of compilers, interpreters and other tools and programs installed on this machine that never go near any privileged directories. Node.js, clang/LLVM, GCC, Scala, Verilog, most of the languages i...
by jahboater
Sun Jun 16, 2019 5:58 pm
Forum: Other programming languages
Topic: ScriptBasic
Replies: 1110
Views: 27535

Re: ScriptBasic

Heater wrote:
Sun Jun 16, 2019 5:09 pm
I normally install .deb files with dpkg -i

A install that works from the gitlab repo and does not require root privs is what we need.
You will always need root privs to install things on Linux?

I hope so anyway.
by jahboater
Sun Jun 16, 2019 5:52 pm
Forum: Beginners
Topic: setting up a RP headless from a ubuntu laptop
Replies: 3
Views: 146

Re: setting up a RP headless from a ubuntu laptop

The simplest solution for image writing is to use the Etcher software ( https://www.balena.io/etcher/ ), which will extract, write and verify the image in one operation. Ubuntu could also use the dd or cp commands, but you'll need to extract the image first, and there's no verification. You can ver...
by jahboater
Sun Jun 16, 2019 5:33 pm
Forum: General discussion
Topic: raspberry pi 3B underclock
Replies: 15
Views: 498

Re: raspberry pi 3B underclock

My issue is that it: - uses more power than asked - produces more heat than asked The heat is easily dealt with:- https://www.kintaro.co/products/kintaro-custom-heatsink For power consumption, arm_freq=800 or something should also reduce the core voltage. For example, Pi Zero's come with a factory ...
by jahboater
Sun Jun 16, 2019 3:51 pm
Forum: General discussion
Topic: raspberry pi 3B underclock
Replies: 15
Views: 498

Re: raspberry pi 3B underclock

Its not an answer, but can I suggest getting a Pi3B+ (with the plus) ? This revision of the Pi3 has extensive changes to improve the thermal management. There is a heat spreader on the SoC chip and the PCB ground plane itself is designed to conduct away heat from the SoC. In addition, changes to the...
by jahboater
Sun Jun 16, 2019 3:41 pm
Forum: Off topic discussion
Topic: how heavy is raspbian ?
Replies: 30
Views: 908

Re: how heavy is raspbian ?

For each instruction count the set bits with __builtin_popcount() or use Brian Kernighan’s algorithm.
Set bits have more electrons in the memory cells.

On the Pi,
a particular add insn opcode is 0x030080E0 (6 set bits)
and sub is 0x034054E0 (9 set bits)
so subtract is heavier than add.
:)
by jahboater
Sat Jun 15, 2019 11:11 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 544
Views: 14918

Re: A Final Fibonacci Challenge

DougieLawson wrote:
Sat Jun 15, 2019 10:45 pm
I didn't look at whether I could get to 128-bit integers with GMP (that's for another day).
GMP is arbitrary precision.
You can, for example, compute the million digit fibo(4784969) simply with:

mpz_fib_ui( res, 4784969 );

which executes in 38 milliseconds on my 7 year old Intel PC.
by jahboater
Sat Jun 15, 2019 11:04 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 544
Views: 14918

Re: A Final Fibonacci Challenge

I reckon fib(92) is about the limit in a 64-bit long long integer. I found a really quick Javascript page at http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fibCalcX.html (which, probably, does more maths than EJolson was looking for). This is even simpler (and includes an overflow che...
by jahboater
Sat Jun 15, 2019 10:59 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 544
Views: 14918

Re: A Final Fibonacci Challenge

ScriptBasic wrote:
Sat Jun 15, 2019 10:30 pm
What other popular languages use GMP for BIGINT support?
do an apt-cache search gmp
Lots of noise, but I can see perl, ocam, php, ada, python (gmpy), gambas?, possibly free pascal,
and obviously C and C++, since GMP is written in C, for C.
by jahboater
Fri Jun 14, 2019 9:20 am
Forum: C/C++
Topic: how to use pthread_kill(pthread_t tid, int sig) by which sig ?
Replies: 19
Views: 401

Re: how to use pthread_kill(pthread_t tid, int sig) by which sig ?

I don't know how to create an experimental setup which simulates such an event, tbh How are you going to test it? Perhaps just change the pthread_kill() call to be unconditional, or based on something external that you can control, like the presence of a file. Use your imagination. The great thing ...
by jahboater
Fri Jun 14, 2019 8:55 am
Forum: C/C++
Topic: how to use pthread_kill(pthread_t tid, int sig) by which sig ?
Replies: 19
Views: 401

Re: how to use pthread_kill(pthread_t tid, int sig) by which sig ?

thank you, so: if I command from a very high prio thread pthread_kill(tid, 9) will that definitely cause the other (stalling) thread tid to stop unconditionally, is that correct? Should do. To be honest I haven't tried it on a thread like that, but "kill -9 <pid>" is just standard stuff. You should...
by jahboater
Fri Jun 14, 2019 8:49 am
Forum: C/C++
Topic: how to use pthread_kill(pthread_t tid, int sig) by which sig ?
Replies: 19
Views: 401

Re: how to use pthread_kill(pthread_t tid, int sig) by which sig ?

dsyleixa123 wrote:
Fri Jun 14, 2019 8:42 am
thank you,
but out of interest:
what stands 9 for?
SIGKILL
Its the strongest signal.
There may be a more suitable signal to stop a thread.
SIGTERM is another one to try.
by jahboater
Fri Jun 14, 2019 7:27 am
Forum: C/C++
Topic: Setup Cross-Compile chain for RPi3
Replies: 7
Views: 1050

Re: Setup Cross-Compile chain for RPi3

I'm speaking in general, I write code on my pi0w and compile it there. From that build I can deploy and run that code on any pi including a pi3 b+. The Pi Zero is pretty slow, so I write the code and debug it on a Pi 3B+ or an Intel PC. My makefile sets the optimal compiler flags for each platform ...
by jahboater
Fri Jun 14, 2019 7:06 am
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 544
Views: 14918

Re: A Final Fibonacci Challenge

That a lot of redundant memory allocation and copying going on. The price of seamless integration., 8-) The C++ integration which looks very seamless, doesn't do all that (see the example and link in my previous post). The problem is, as always, mixing two languages where one language has a richer ...
by jahboater
Fri Jun 14, 2019 6:52 am
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 544
Views: 14918

Re: A Final Fibonacci Challenge

I think people don't like > 1111 + "1111" '11111111' > 1111 - "1111" 0 because of its inconsistency. "-" does arithmetic "+" does string concatenation one operator converts the number to a string the other converts a string to a number. There are many C++ interfaces for GMP, I see there is now one p...
by jahboater
Thu Jun 13, 2019 11:39 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 544
Views: 14918

Re: A Final Fibonacci Challenge

Can someone suggest what GMP divide function would be best. There seems to be a few options for the operator. I suggest the "tdiv" functions for truncating integer division (that is, they truncate towards zero like normal hardware integer divide works). mpz_tdiv_q() etc. 7/2 == 3 and -7/2 == -3 4/5...
by jahboater
Thu Jun 13, 2019 3:24 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 544
Views: 14918

Re: A Final Fibonacci Challenge

If you are talking about C then it is simple (though it may not appear so!) It's got me mystified, how one can concatenate strings and return that from a function - char * GetErrorMessage(int n) { char * errorMessage = ConcatenateStrings("Error is: ", intToString(n)); return errorMessage; } Probabl...
by jahboater
Thu Jun 13, 2019 3:07 pm
Forum: General programming discussion
Topic: A Final Fibonacci Challenge
Replies: 544
Views: 14918

Re: A Final Fibonacci Challenge

If it is leaking, I can add a static function to do the clear before exiting the function. It's always been a mystery what is freed when exiting a function and what manually needs to be freed. Strings seem to be the major concern. If you are talking about C then it is simple (though it may not appe...
by jahboater
Thu Jun 13, 2019 3:00 pm
Forum: Troubleshooting
Topic: raspbian.raspberrypi.org down?
Replies: 5
Views: 138

Re: raspbian.raspberrypi.org down?

Just an "apt update" and its fine.
by jahboater
Thu Jun 13, 2019 2:30 pm
Forum: Beginners
Topic: How would I only boot into one program and not a full blown OS
Replies: 13
Views: 353

Re: How would I only boot into one program and not a full blown OS

You can boot a single program by putting its name on the kernel command line. In: /boot/cmdline.txt add (on the same line): init=path_to_program For example: init=/bin/bash would drop you into a shell without starting systemd, the gui, or any of the services. Try that, and from there you can see wha...

Go to advanced search