Go to advanced search

by jahboater
Thu Aug 10, 2017 7:17 am
Forum: C/C++
Topic: Sampling with C and MCP3008
Replies: 8
Views: 3473

Re: Sampling with C and MCP3008

Perhaps try the newer POSIX clocks to get more accurate times. It gives you a choice of clocks and probably a lower overhead. gettimeofday() only supports the unreliable TOD (wall-clock) time (and is obsolete). The wall clock time is constantly being adjusted by NTP. struct timespec tv1; clock_getti...
by jahboater
Thu Aug 10, 2017 6:58 am
Forum: Advanced users
Topic: USB-only mode. Can I still use SD card if needed?
Replies: 9
Views: 2121

Re: USB-only mode. Can I still use SD card if needed?

triplus wrote:
Thu Aug 10, 2017 6:50 am
While this seems like an interesting opportunity to lower the SD card corruption (which I'm battling right now on my Pi)
Perhaps the first thing to do is to investigate why you get the SD card corruption?
by jahboater
Thu Aug 10, 2017 6:20 am
Forum: Beginners
Topic: How can I check the speed of my micro sd card from my Raspberry Pi 3 Raspbian Install?
Replies: 1
Views: 1022

Re: How can I check the speed of my micro sd card from my Raspberry Pi 3 Raspbian Install?

Try adding dtparam=sd_overclock=100 to you /boot/config.txt file. hdparm (see below) went from 21 MB/sec to 34 MB/sec and the boot time (see "systemd-analyze") went down to 5 seconds. How can I check the speed of my micro sd card from my Raspberry Pi 3 Raspbian OS? There are various methods, I use: ...
by jahboater
Wed Aug 09, 2017 3:30 pm
Forum: Interfacing (DSI, CSI, I2C, etc.)
Topic: To "sudo echo..." or not to "sudo echo..." to /dev/spidev... ?
Replies: 18
Views: 6076

Re: To "sudo echo..." or not to "sudo echo..." to /dev/spidev... ?

In C, could you perhaps just write to the file as usual, instead of "system();" which seems an error prone and inefficient way of doing it. Something vaguely like :- int fd = open( "/dev/spidev0.1", O_WRONLY ); write( fd, "\x0f\x01", 2 ); Call close(fd) after the last write and add checks after each...
by jahboater
Wed Aug 09, 2017 8:04 am
Forum: Beginners
Topic: NTP / time settings
Replies: 27
Views: 145098

Re: NTP / time settings

To set the time zone without adding symlinks by hand:

Code: Select all

sudo dpkg-reconfigure tzdata
by jahboater
Mon Aug 07, 2017 10:00 am
Forum: Other programming languages
Topic: Register allocation (assembly language)
Replies: 32
Views: 7866

Re: Register allocation (assembly language)

I recall there was a lot of debate about the implementation of min and max in the Linux kernel. Linus finally dictated that the following shall be used: #define max(x, y) ({ \ typeof(x) _max1 = x; \ typeof(y) _max2 = y; \ (void) (&_max1 == &_max2); \ _max1 > _max2 ? _max1 : _max2; }) What does he k...
by jahboater
Sun Aug 06, 2017 4:01 pm
Forum: Other programming languages
Topic: Register allocation (assembly language)
Replies: 32
Views: 7866

Re: Register allocation (assembly language)

Interesting! First of all the final cast seems unnecessary, because you already converted b to typeof(a) when assigning to t2. I added the final cast in case the result type was smaller than an int. char a,b,c; a = max( b, c ); must not raise a narrowing conversion warning after the automatic promot...
by jahboater
Sun Aug 06, 2017 11:04 am
Forum: Other programming languages
Topic: Register allocation (assembly language)
Replies: 32
Views: 7866

Re: Register allocation (assembly language)

Personally I find all that macro stuff in C totally objectionable. Now you are writing code in preprocessor language not C syntax. (Yeah, I know the preprocessor is specified in the C standards, it's crap anyway.) What prompted that? Presumably my min/max macros. #define max(a,b) ({ const typeof(a)...
by jahboater
Sat Aug 05, 2017 7:30 pm
Forum: Other programming languages
Topic: Register allocation (assembly language)
Replies: 32
Views: 7866

Re: Register allocation (assembly language)

C++ recently acquired support for lambdas, in it's typical clunky manner. That is not really the same as nested functions. For example, can I have a lambda in C++ that I can pass to any other function. And still have it work when the creator of the lambda has returned? I'm not an expert on recent C...
by jahboater
Sat Aug 05, 2017 7:41 am
Forum: Raspberry Pi OS
Topic: ext4 inode ratio
Replies: 14
Views: 2688

Re: ext4 inode ratio

I asked because maybe it was something like "you add -ratio 4096 to the dd command", but since it isn't; I let time solve problems, it usually does. See "man mkfs.ext4", its the "-i" option. But note the warning ... -i bytes-per-inode Specify the bytes/inode ratio. mke2fs creates an inode for every...
by jahboater
Sat Aug 05, 2017 12:16 am
Forum: Other programming languages
Topic: Register allocation (assembly language)
Replies: 32
Views: 7866

Re: Register allocation (assembly language)

while (({int i; scanf("%d", &i) && i!=42;})); What you say may be useful. But most places I have worked would fire you if you insisted on writing such inscrutable code. It's hard for humans to parse and it's unnecessary. It is just a compound statement that can return a value (like a serial clause ...
by jahboater
Fri Aug 04, 2017 9:43 pm
Forum: Other programming languages
Topic: Register allocation (assembly language)
Replies: 32
Views: 7866

Re: Shortcomings of C

the lack of compound expressions containing declarations. E.G., in gcc you can write while (({int i; scanf("%d", &i) && i!=42;})); BCPL had these. I don't know why they were dropped in B and C. Very useful. There are quite a few handy gcc extensions. case '0' ... '9': // saves a whole lot of case v...
by jahboater
Fri Aug 04, 2017 3:27 pm
Forum: Other programming languages
Topic: Register allocation (assembly language)
Replies: 32
Views: 7866

Re: Register allocation (assembly language)

(I wrote some code that allocates regs for a BB but it doesn't take the R0-3 vs. R4-11 thing into account. Should 'BL' end the current BB? Strictly speaking, as a branch, it should, but semantically it's like a non-branching instruction that potentially does a lot.) I'm not sure what you mean by BB...
by jahboater
Fri Aug 04, 2017 2:11 pm
Forum: Raspberry Pi OS
Topic: ext4 inode ratio
Replies: 14
Views: 2688

Re: ext4 inode ratio

bullen wrote:
Fri Aug 04, 2017 8:10 am
Hi, how can I change the inode ratio to say (4096 bytes per inode) before I install raspbian lite?
Why so low?
With the default 4k block size some of the inodes can never be used, even though most of your data files might be very small.
by jahboater
Fri Aug 04, 2017 11:12 am
Forum: Other programming languages
Topic: Register allocation (assembly language)
Replies: 32
Views: 7866

Re: Register allocation (assembly language)

I did think of this algorithm: Generate crappy code; do Fix and/or improve the code until Can't think of anything else to do. but I'm sure there's a better algorithm! Thats not a bad idea if you are writing the compiler just for fun. Perhaps just allocate the registers one by one until you run out,...
by jahboater
Fri Aug 04, 2017 7:45 am
Forum: Beginners
Topic: Opinion: Power supply.
Replies: 8
Views: 4645

Re: Opinion: Power supply.

This is the spec for the "official" Pi3 power supply. http://www.farnell.com/datasheets/2020879.pdf It is high quality and works very well for all Pi models including the Zero. The lead is a hefty 18AWG. For what you get, and peace of mind, the price is very reasonable. How many other power supplies...
by jahboater
Fri Aug 04, 2017 7:10 am
Forum: Other programming languages
Topic: Register allocation (assembly language)
Replies: 32
Views: 7866

Re: Register allocation (assembly language)

You might be thinking, "hmm, I could write some clever sed rules to do all that for me" but honestly, I think you might find that it's been done and they call it something like 'cc'. I think the OP is writing a compiler. It is hard - the current register allocator in gcc was some 20 years in develo...
by jahboater
Thu Aug 03, 2017 10:28 pm
Forum: Off topic discussion
Topic: IBM's world record: 330TB uncompressed data on a palm-sized tape cartridge
Replies: 15
Views: 4344

Re: IBM's world record: 330TB uncompressed data on a palm-sized tape cartridge

IBM *did* have a "Tape Operating System" (TOS, mostly for banks) back in the mid-1960s. Seagate did have a Tape Filing System with random access tapes. I used it on a Windows 98 PC with a 2GB DAT drive. It wasn't great, random access was up to 30 seconds. I still have a few old tape drives around (...
by jahboater
Thu Aug 03, 2017 9:51 pm
Forum: Troubleshooting
Topic: I am unable to install Raspian on a microsd card
Replies: 8
Views: 1247

Re: I am unable to install Raspian on a microsd card

It could be superstition too but a lot of times, especially with cards that don't seem to want to boot, starting over with a new partition table will get them going again. It may (though I suspect it is superstition). But if you subsequently overwrite that "new partition table" with a Raspbian imag...
by jahboater
Thu Aug 03, 2017 3:57 pm
Forum: General discussion
Topic: Corrupt SD card -- guide
Replies: 38
Views: 71781

Re: Corrupt SD card -- guide

Now I'm really worried -- months of code written in Python. You only have one copy of months of work? If it was important you'd have several copies in several different places. Decades ago, a PHD student came to me with a problem, his thesis which he had spent 3 years working on, was on a computer ...
by jahboater
Thu Aug 03, 2017 3:36 pm
Forum: General discussion
Topic: Unable to use Eclipse to write C++ code
Replies: 2
Views: 618

Re: Unable to use Eclipse to write C++ code

Just a minor point, you do not need eclipse to write C++ code on the Pi!
by jahboater
Thu Aug 03, 2017 7:24 am
Forum: Other programming languages
Topic: Register allocation (assembly language)
Replies: 32
Views: 7866

Re: Register allocation (assembly language)

Are you interested in performance?

If so you also need to worry about avoiding dependencies and allowing multiple issue and so on.

Some ARM cpu's with out-of-order execution can deal with dependencies themselves to a degree, but the Pi cpu's are low power, or old designs, so cannot.
by jahboater
Wed Aug 02, 2017 4:43 pm
Forum: Other programming languages
Topic: Register allocation (assembly language)
Replies: 32
Views: 7866

Re: Register allocation (assembly language)

Wait till you use the Pi in 64-bit mode, there are 31 general purpose registers, plus the handy zero register! What you describe is just normal assembler programming, if you don't like it, use C instead and the C compiler's register allocator and scheduler will do a great job, probably better than u...
by jahboater
Wed Aug 02, 2017 2:02 pm
Forum: Beginners
Topic: Buggy text when editing files with nano through terminal
Replies: 7
Views: 860

Re: Buggy text when editing files with nano through terminal

I assume $TERM is set correctly?
It should usually default to "xterm".
by jahboater
Wed Aug 02, 2017 1:07 pm
Forum: General discussion
Topic: checking system stats from c
Replies: 1
Views: 478

Re: checking system stats from c

but I'm not sure about cpu usage. I can't parse the output of top. Any suggestions would be welcome. You could open "/proc/stat" periodically. Subtracting the figures each time should give you the CPU used in the interval (there is no such thing as %cpu usage, a cpu is either running or it is not -...

Go to advanced search