×

Announcing: Slashdot Deals - Explore geek apps, games, gadgets and more. (what is this?)

Thank you!

We are sorry to see you leave - Beta is different and we value the time you took to try it out. Before you decide to go, please take a look at some value-adds for Beta and learn more about it. Thank you for reading Slashdot, and for making the site better!

Comments

top

Ask Slashdot: Is Pascal Underrated?

psmears Re:Modula-3 FTW! (433 comments)

[1] It could be a macro, but most coding conventions require macros that can't be used as if they were functions to be all-caps.

Or x could be an array... in which case the called function can modify the value of the variable. The point you're making is valid, but C isn't 100% consistent in this regard :)

7 hours ago
top

Ask Slashdot: Is Pascal Underrated?

psmears Re:Modula-3 FTW! (433 comments)

IIRC, pascal begin/end are not optional.

If body of the "if" (or "while" etc) is a single (simple) statement, then "begin" and "end" are optional - so you can write either

if cond then
begin
do_stuff()
end

or

if cond then do_stuff()

7 hours ago
top

Ask Slashdot: Is Pascal Underrated?

psmears Re:Modula-3 FTW! (433 comments)

For example, you can compare the readability of Arabic numbers vs Roman numerals by asking two people proficient in each to perform the same arithmetic calculations, and you time them.

That would measure how easy it is to perform arithmetic in the two systems... which is not the same as readability. Similarly it's a good idea not to confuse "easy for a computer to read (and execute)" vs "easy for a human to read (and understand)" - both are important in different ways, but they are entirely separate concerns!

7 hours ago
top

Why Run Linux On Macs?

psmears Re: a better question (588 comments)

Perhaps you should once google what QMX actually is, so you relize it has nothing to do with 'process control'.

QNX, not QMX. It's a hard-realtime microkernel OS. That doesn't mean it can do process control on its own, but the realtime features are handy if that is what you want to do with it.

about a week ago
top

SystemD Gains New Networking Features

psmears Re: Fuck Me (552 comments)

RISC OS had (limited) support for pre-emptive multi-tasking too, in the form of the TaskWindow stuff.

about two weeks ago
top

How We'll Program 1000 Cores - and Get Linus Ranting, Again

psmears Re:Programs people want to use... (449 comments)

Why haven't you written such a thing before? Because it's too much hassle. Which is the very reason threading is underused.

LOL. Actually there's a better reason such a thread launch facility doesn't commonly get written - which is that, in most circumstances, it really doesn't help performance that much, if at all - and the added complexity makes for a big net minus. There are a number of issues:

Firstly, spawning threads is expensive. Yes, on Linux it's "cheap", but that's "cheap" compared to other implementations - it's still a lot compared to doing a modest amount of work on the local CPU. (Why is it so expensive? Basically because there's a lot of housekeeping to do. In addition to the kernel creating new kernel structures for the new thread of execution (similar to creating a process), the process's thread library must allocate a stack for the new thread (involving modifying the process's page tables), iterate through all loaded shared libraries in order to allocate any thread-local storage they require, and so on, requiring multiple syscalls, a TLB flush, at least one context switch, and so on. To some extent the impact of this overhead can be reduced by maintaining a pool of ready-created threads, but this either takes away control of performance (if done automatically by your language/library) or substantially increases complexity (if you implement it yourself, since you then have to synchronise the threads carefully).

The second problem is that, unless you're very careful, extra threads don't buy you much performance, and can indeed hurt. Take the example you gave - doing some processing on each struct in an array, where each such struct contains an int and a double (16 bytes total, including alignment padding). With 64-byte cache lines (typical on x86), there are 4 such structs per cache line. If you distribute the processing over threads running on different cores, then instead of one core waiting for the cache line to come in to main memory, and then processing the 4 structs very rapidly (since they're now all in cache), you'll have 4 cores each waiting for the data to be available - i.e. up to a 4x slowdown for memory-bound tasks. And that's assuming the structure is only read from; if it's written to as well then the cache line will have to bounce between cores, and the multithreading slowdown will be many times worse. Now, if you ensure that structs in the same cache line get processed by the same core (ideally in sequence, and by the same kernel thread), then you do potentially get a big speedup - provided you don't hit any other gotchas - but the C++ code you're promoting doesn't seem to guarantee this in any way.

Third, and perhaps most importantly, data dependencies matter. In your example you're detaching all the threads; this is not realistic, because that means you cannot ever depend on their operations having finished. In the vast majority of cases you do need to know when an operation has finished: you're generally doing work for a reason - i.e. that you're going to use the result - and you can't begin to use that result until you know it has been produced. That, in of itself, adds complexity: you have to analyse your program's dataflow much more carefully in the presence of threads, because C/C++ will quite happily let you use a variable before another thread has finished assigning to it, without any sort of warning or exception. The analysis can certainly be done, and synchronisation put in place to eliminate the problems - but that is further overhead, both in the program's performance but also in the complexity of the program itself, and hence the time taken to write it (and especially to enhance it later, when the synchronisation model may not be so fresh in one's mind).

Used correctly and in the right circumstances, threads on an N-core system can give a N-times speedup (or greater, due to caching effects). Used badly, at best they'll reduce performance, and usually they'll increase complexity and lead to subtle bugs that are hard to debug.

The new thread features in modern C++ are very cool, but the fact they didn't exist before is not what's been preventing competent programmers from using threads all over the place :)

about three weeks ago
top

What is your computer most often plugged into?

psmears Re:UPS (236 comments)

you've not considered that the UPS going bang is infinitely better than your PC going bang..

The trouble is that, even with a UPS, my PC can decide to go bang of its own accord - so I need to solve that problem too :-/

about 2 months ago
top

UK Hotel Adds Hefty Charge For Bad Reviews Online

psmears Re:Contracts (307 comments)

Retail or not, contracts are binding.

Contracts tend to be binding even when both parties don't read--most contracts are not read but are binding

Are you sure about that? Note the following (from the American Law Institute):

Where the other party has reason to believe that the party manifesting such assent would not do so if he knew that the writing contained a particular term, the term is not part of the agreement.

i.e. if you put terms into a contract that you know your customers aren't likely to agree to, then they're not binding, even if the contract is signed.

about 2 months ago
top

Black IT Pros On (Lack Of) Racial Diversity In Tech

psmears Re:Yeah, right... (459 comments)

Vegan pizzas seem like a waste of time (iirc Vegans don't do cheese?).

Vegetarian pizzas? Fine, no problem.

The majority religion in India is Hinduism; many adherents do not eat meat or eggs, but will generally eat dairy products, including cheese. So yes, vegetarian rather than vegan :-)

about 2 months ago
top

How To End Online Harassment

psmears Re:Not this shit again (834 comments)

Thanks - that didn't come up in my search results for some reason :-/

about 2 months ago
top

How To End Online Harassment

psmears Re:Not this shit again (834 comments)

None of it, expect of course that the University of Utah confirmed it, and a lot of people there have received this message. Read it for a fine example of crazy reactionary misogyny.

University of Utah confirmed that threat was completely un-credible and there was no credible threat to the students or anyone else. Once again you are so woefully uninformed about the most basic of facts that I wonder if you even so much as googled any of this before posting.

I couldn't find a source to back that up; instead, googling showed that the University of Utah prepared to enhance their security as a direct result of the threat. Or did I miss something? It's admittedly quite hard to search for without the results getting swamped with gamergate coverage of one sort or another...

about 2 months ago
top

How To End Online Harassment

psmears Re:You REALLY want to go down that road? (834 comments)

I lost count at 30 people doxxed by those that claim to stand for "feminism" and against gamergate, starting with the black developer who lost his job to racists harassing his boss and going downhill from there to people's bank accounts getting hacked, their utilities turned off, their income held up by fraud, a couple attempts at SWATting, and even syringes, knives, and dead animals in the mail.

I've missed all this... do you have any links?

about 2 months ago
top

How To End Online Harassment

psmears Re:Additional... both sides are showing bad behavi (834 comments)

Many of the journalists and supporters of the anti GG side have doxxed people... with their main accounts in the clear. Not sock puppet accounts that could be anyone. But they did it directly.

I haven't seen any of this; do you perhaps have a link?

I don't know why people keep bringing up harassment like this helps the anti GG side because the anti GG side has harassed far more.

Who said "we should bring back bullying" was that GG or anti GG? Anti GG. Every single fucking time.

I did see that one (only once though); at least the idiot in question apologised...

So they have no moral high ground there and I just thought that should be made very fucking clear. To the contrary, it is they that should be apologizing and explaining their own behavior which has been far worse.

People prominent in GG have received death threats, have had people call their work and tell their employers they're pedophiles, have had things mailed to their homes like knives or syringes...

Do you have any links about these?

about 2 months ago
top

How To End Online Harassment

psmears Re:Not this shit again (834 comments)

Every attacker of gamergate has been violent, sending death threads, making up BLATANTLY fake images to make themselves look like victims, and very publicly attacking people on Twitter as well.

I've got to confess I haven't seen any of this. Do you have a link?

about 2 months ago
top

The Effect of Programming Language On Software Quality

psmears Re:Take away for me (217 comments)

the preference of certain personality types for functional, static and strongly typed languages.

Translation: because only very high-skill programmers attempt to use the very unpopular functional languages (like lisp and erlang) the resulting code is, on average, of better quality.

There is another possible interpretation: that programmers who are very concerned about quality - and hence are happy when their language gives them lots of information about potential mistakes - like using languages with features (such as a strong type system) designed to allow detection of certain types of mistake. That is, it's specific features of the languages, rather than the fact that the languages are "unpopular", that draws quality-focussed programmers to them.

Of course, that is just as much conjecture as any other interpretation :-)

about 3 months ago
top

New Atomic Clock Reaches the Boundaries of Timekeeping

psmears Re:Old saying (249 comments)

No: basic geometry dictates that, to find a position in three dimensions, you need three measurements of distance.

Yes! Why are you assuming there is no distance information? There is!

What I said was that there is no distance information in the message received from the satellite. Of course you can derive distance information, or else GPS wouldn't work at all :-)

and the time by that satellite's clock - but since you have nothing to compare it against, you have no idea how long that signal took to reach you, so you get no information about your position.

This is where you're falling down. Of course you have things to compare it to. For each satellite, you have consecutive signals giving you new coordinates and a new time reference. You can calculate the distance between those two points. Then you can calculate the change in the difference between the timestamp in the signal and its arrival time. This actually gives you very good distance information, although of course it isn't static. (It could not be.)

Right - but there are two problems with this. One is that, by taking measurements over time, you do indeed get more information - but you also introduce more unknowns, because now you have to take into account the fact that you are likely to be moving - so you can't tell what part of the difference in the satellite signal is due to the satellite's motion, and which is due to yours. The other is that, even if you're guaranteed to be stationary, for your different readings from the same satellite to be useful, the satellite has to have moved a substantial distance, or else the errors in measurement will be relatively large compared to the change in timestamp difference - so you can't do an accurate calculation of your position. (This is why receivers won't give you a position readout even if they have 4 satellites, if those 4 satellites are very close together in the sky.) In practice it takes of the order of hours for the satellite to move sufficiently (which then introduces other problems - the quartz-based clocks in typical GPS receivers are not sufficiently accurate over such long periods.)

You can also make comparisons between the satellites. That only gives you relative, rather than absolute, distances,

Yes - which is exactly what I said :-) But differences only give you N-1 measurements for N satellites.

about 3 months ago
top

New Atomic Clock Reaches the Boundaries of Timekeeping

psmears Re:Old saying (249 comments)

Yes, I know you can do that, I even mentioned it :) But the person I was repying to claimed "3 satellites are sufficient to find your basic location and elevation" (emphasis mine) - i.e. they were claiming you could find the distance from the centre of the Earth, without assuming it.

No. You are finding your distance from the satellites. Not from the center of the Earth.

Umm... if you're claiming you can find your elevation, then you can find your distance from the centre of the Earth. It's more or less the same thing :-). I agree you can use the measurements from the satellites though (i.e. you don't need to know any information about your elevation a priori).

But since the 3-D positions of the satellites are known to a fine degree of accuracy, that's all you need.

I agree that the position of each satellite is known, to high accuracy. That's not the issue - the issue is that, if you have a signal from one satellite, that doesn't tell you your distance from that satellite. The signal basically says "I am satellite 7, I am at (position), and the time by my clock is (time)", and that is all your receiver receives. Receiving that signal tells you nothing about your position (well, possibly you can tell which hemisphere you're in from the fact that the satellite is visible at all, but that doesn't narrow things down much!). You only start getting information about your position when you have signals from more than one satellite, because then you can compare the timestamps - the difference in the timestamps gives you information about the difference in the distance from you to the two satellites.

And yes, 3 points and 3 distances is all you need to find a point in 3D space. It actually defines 2 points, but as mentioned before one is out in space so it obviously doesn't count. The other one is on the surface of the Earth (or in a plane, or whatever).

I agree that 3 points and 3 distances is all you need. The trouble is that the signal from 3 satellites only gives you 2 distances (unless, as jfengel mentions, you happen to be carrying round an atomic clock with you - which is generally not practical!).

You still need to think about probability, because the elevation model only tells you where the ground is - not where you are in relation to it. That said, the asumption "you're probably very close to the surface" is often very good, at least for most people :-)

No. Again, the orbits (and therefore positions) of the GPS satellites are known very precisely. As long as you can receive the signals from them, you could be above the ground, or below the ground, or even at the center of the Earth (at least theoretically), and still get your position and "elevation", even though it may be negative. Probability is not a factor at all, though accuracy certainly is. There are errors that have to be accounted for.

I mention probability because, even in the absence of 3 distances to give you a full 3D fix, you can use the fact that, statistically speaking, most people spend most of their time very close to the Earth's surface, to give a good estimate for one of the distances (i.e. estimate "I'm probably at or near ground level"), which then generally gives a pretty good estimate of your horizontal position. This is why even a 2D GPS fix is very useful in practice. But even if you have a signal from 4+ satellites, probability still comes into play: you have to account for radio interference, atmospheric effects and multipath effects, inaccuracies in the receiver's clocks, rounding errors, etc. etc., each of which adds uncertainty to the measurements and calculations and hence to the ultimate position readout.

about 3 months ago
top

New Atomic Clock Reaches the Boundaries of Timekeeping

psmears Re:Old saying (249 comments)

you need three measurements of distance.

Yes, and one of those measurements come from knowing your distance from the center of the Earth.

Yes, I know you can do that, I even mentioned it :) But the person I was repying to claimed "3 satellites are sufficient to find your basic location and elevation" (emphasis mine) - i.e. they were claiming you could find the distance from the centre of the Earth, without assuming it.

Sure, if you look at probability distributions of height ...

Except you don't need to look at probability distributions. GPS setups meant for use in areas with possibly limited reception and no nearby ground station/LORAN alternative to help deal with that can use a detailed elevation model of the Earth to narrow things down quite a bit.

You still need to think about probability, because the elevation model only tells you where the ground is - not where you are in relation to it. That said, the asumption "you're probably very close to the surface" is often very good, at least for most people :-)

about 3 months ago
top

New Atomic Clock Reaches the Boundaries of Timekeeping

psmears Re:Old saying (249 comments)

No, it is NOT wrong. Your assertion is a common misconception. I assure you: I looked into this technology in depth.

Then perhaps you can provide a reference?

Just as basic geometry would normally dictate, 3 satellites are sufficient to find your basic location and elevation.

No: basic geometry dictates that, to find a position in three dimensions, you need three measurements of distance. The trouble is that the signal from one satellite gives you no information about your position: the signal (roughly speaking) tells you where the satellite is, and the time by that satellite's clock - but since you have nothing to compare it against, you have no idea how long that signal took to reach you, so you get no information about your position.

It's similar to if you asked me my height, and I said "I'm a foot taller than Fred". If you don't know how tall Fred is, you're no nearer to knowing how tall I am, even though you've been given one measurement. Sure, if you look at probability distributions of height you can have a good guess at how tall I might be, and this is similar to getting a 2D fix (where you assume that your elevation is "at or near the surface of the Earth"), but you can't know for certain that one of both of us don't have unusual heights.

Once you have a signal from two satellites, you can subtract the timestamps, which doesn't directly tell you position, but tells you which satellite is closer to your position, and by how much. This allows you to constrain your position in one dimension (i.e. you still have two degrees of freedom - a surface rather than a solid), and another satellite's signal will give you another constraint (pinning you down to a line); only with a fourth satellite can you determine your position precisely (well, actually the solution can give more than one point but generally only one is realistic).

about 3 months ago
top

Ask Slashdot: Can You Say Something Nice About Systemd?

psmears Re:One more thing I don't like about systemd. (928 comments)

If it has been so well thought out, then why isn't there a parameter available for each service that says "don't automatically restart this if it fails"?

There is... and the default is (I believe) not to restart.

about 3 months ago

Submissions

top

UK DNA database ruled a 'breach of rights'

psmears psmears writes  |  more than 6 years ago

psmears writes "Describing a judgment that is likely rein in the scope of the UK DNA database, where at present the DNA of those arrested by the police is kept permanently (even if the people concerned are never convicted, or even charged), the BBC reports that the European Court of Human Rights has ruled that keeping such people's DNA in the database 'could not be regarded as necessary in a democratic society'."
Link to Original Source

Journals

psmears has no journal entries.

Slashdot Login

Need an Account?

Forgot your password?