flat assembler
Message board for the users of flat assembler.

Index > Heap > Interesting article about taboos in programming.

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
it's almost impossible to make some real error handling in structured programming without try/catch
Post 13 Aug 2006, 19:56
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
0x4e71



Joined: 25 Feb 2004
Posts: 50
0x4e71
f0dder wrote:
0x4e71 wrote:

I don't know if there is a posix (or Linux for that matter) equivalent to VirtualAlloc(), I find it a tremendously useful function, especially the possibility of allocating a chunk of address space without committing pages to it, then allocate memory to it later as buffers grow...

I think the linux equivalent of VirtualAlloc would be mmap()... just hope it's done differently than on windows, pagefaults are expensive.

Thanks, I'll look into mmap

f0dder wrote:

0x4e71 wrote:

All of the Console functions, you have ONE reasonable way to read everything, key events, state of SHIFT/CTRL/ALT (try that on unix without ioctl and other horrible tricks), mouse events, console resize events. Plus access to attributes and block commands for output. A+

ioctl() isn't *that* horrible, as long as it's documented. Of course I prefer named API calls instead of direct ioctl(), but you can always write wrappers. It's all about r3->r0->r3 in a controlled manner, anyway. Haven't traced/disasmed the console APIs on NT, but I wouldn't be surprised if they end up sending IRPs to a device driver.

It is *quite* horrible when you compare it to the win32 console functions Wink because those are clean and consistent interface exposed to the application, no matter how they are implemented internally. Additionally ioctl won't work when you run within an xterm, so you get more special handling and inconsistency. Bad! (BTW, the win32 console functions ALSO behave as expected when you run an app over the telnet client IIRC.

f0dder wrote:
0x4e71 wrote:

Abominations such as CreateFile() (contra-intuitive name, 7 parameters, deprecates _lopen) and ImpersonateNamedPipeClient() are not in scope for me Wink

CreateFile should really have been named CreateObject Razz. It's a bit over the top in some ways, but on the other hand, it offers you a shitload of functionality... cache hints, buffered vs. unbuffered, security, ...
I like the idea of ACLs instead of simple user:group permissions - it's more flexible, even though it also gives you greater flexibility of ways in which to shoot yourself in the foot Wink


Oh absolutely, it's great to have that functionality, it should be there but please not in the main function you use to open a file Smile. The point, is 99% of the time ppl just want to open a plain old fashioned file for reading and/or writing... so a good API ALSO provides simple ways of doing the simple, most common things Smile
Post 14 Aug 2006, 08:14
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Back on the subject of "goto"... it's quite fine when used in those few situations where it can actually make code cleaner or more efficient. The problem is, of course, that it's easy to overuse, and can lead to pretty messy code.

If you're doing C++, the "goto cleanup" kind of error-handling can be replaced with resource-acquisition objects. The price you pay in overhead for this is very small, compared to the advantages of cleaner and more robust code it gives.

_________________
Image - carpe noctem
Post 14 Aug 2006, 09:50
View user's profile Send private message Visit poster's website Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica
f0dder wrote:
scientica wrote:

for things like KDE3 it makes a difference (at least pre gcc 4.1 with visibillity-hiding (iirc that's supposed to cut "some" fat of the runtime linking))

Yeah, it did seem to make a little difference when I played with it on a test gentoo install. The point is that it shouldn't make a difference, and shouldn't need to be done. Would be interesting if somebody profiled the load stage of some apps and found out where the bottleneck is. There has to be more to it than just plain dynamic binding... unless there's some really retarded code in the ELF loader. I guess windows has an advantage in requiring the PE exports to be sorted, so it can do a binary search... does ELF do the same?

I'm not up2date on how ELF works on low level, but iirc part of the bloat problem that make prelinking "good" is that (at least with default opts pre gcc 4.x) a metric-tone of unused symbols we're included (taking time in the dynlinker), now we got options like "--as-needed"(ld flag) which:
"The flag tells the linker to link in the produced binary only the libraries containing symbols actually used by the binary itself." (from http://www.gentoo.org/proj/en/qa/asneeded.xml -- useful/interessting reading, gives some more info on the linking problem)
Sadly, a bunch of apps are "broken" wrt --as-needed, but work is in progress to fix it ([swank]I'm using -Wl,--as-needed and I've reported apps that are broken (also submitted a quick-fix for heimdal(just filtering out the flag))[/swank]).
One down side of prelinking is that it in effect voids PIC/PIE, the best it does is randomize the Entry Point (if explicity told).

f0dder wrote:
scientica wrote:

Well, I'd geuss the implementation, as Xgl is better in that part (iirc no 100% cpu while moving, and that's with all the fancy special effects turned on (and the distored window was repainted while beeing moved). The advantage of X is it's network transparency, but that's probably one of the roots of it's performance problems.

Interesting, I guess I ought to test out Xgl (not very intuitive that there's both Xgl and glX, which are different things Smile). My Ubuntu test install was nuked since I needed the disk for something else, but I guess I have some other disk lying around... And yeah, network transparancy is cool, I just hope there's some really efficient special-path socket stuff going on locally, otherwise there's a lot of waste moving buffers around etc.

I'd recomend using the Kororaa Live CD (gentoo based, but alas also GNOME*, but sadly gnome (and xfce4) are the only ones to fully support Xgl yet :/), it's a live CD so it's a bit slower than a "real" install, but it'll give an idea of it - ie if you'd fancy giving an "real" install it a try.
(*@"whe who btoher": I agree with Linus about GNOME, for those who cares here's the thread: (not work safe language in some countries!!) http://lists.osdl.org/pipermail/desktop_architects/2005-December/000395.html )

For "local" X sessions a unix socket is used (think of it as a socket that really isn't running over a network but a IPC-like-thingy-shortcut).

btw, OT: xgl is an implementation on top of X, (redhat) AIX is (iirc) a rewerite, AIX is ment to be the final version (and I think it's faster than Xgl) - xgl is basically a proof-of-concept (well sort of). - at least that's my understanding of it.

f0dder wrote:
scientica wrote:
Well we could always start using ReactOS Very Happy

*grin* - I actually think it's a pretty worthwhile project. The NT kernel *is* a solid piece of engineering, it's all the win32 fluff and badly coded third-party applications that are troublesome.

In all honestly, I actaully liked NT4 and Win2k, and I stand by that Win2k was the last windows I found usable (still, I think linux is better, but in a way it's like comparing apples and pears - windows and linux are like OpenGL and DirectX based on 2 different paradigms but can be used for the same things in most part)

f0dder wrote:
scientica wrote:

Well, now days, as a "normal" user to install windows, well, I don't think the poor bastard would be able to do it (and I doubt it'd make any difference of ine s/windows/linux/ here, installing OS just isn't for "normal users", just like normal people aren't expected to change engine of their cars (now days you almost need to be a greese monkey "just" to change a light bulb in a car (in a few years it will requre one to first lift out the engine....)))

Oh, but I wasn't talking about installing, I was talking about daily use (both windows and linux are generally easy enough to install for power++ users, although linux is at a bit of a disadvantage because most distros gives you a lot of install choices). Power users shouldn't have much trouble using linux for most stuff, but it would be a bad idea trying to get my mum or the museum people to use it...

Well, I think a pre installed linux or windows is just the same for a "normal user", ie, if all it does is check mail, surf, write text doucments/spreadhseets. Ie, all that's different is the name of the app - ie:
IE vs Firefox/Konqueror
Outlook vs. Thunderbird
MS Office vs OpenOffice.org
I mean, most users have windows at home, and sues eg Outlook, but in woork they might use Lotus's mail client - all that's needed for tehm is to be told "use this app for mail", and most apps are pretty standardized - eg mail clients usually have the same sematince "Compose/Write", "Get Mail",...
As a short real life example, my mom uses firefox and thunderbird instead of MS's apps, she's had no problems adpating, all I told her is that she can sue them just as she uses teh MS coutnerparts, also, I installed a MS Outlook theme for Thunderbird and told her "now, you can use this exactly as you used Outlook", and she's had no problems this far. My point beeing, there has evolved a de facto standard interface for most "day-to-day apps", and a far as the end user is concerned who wrote it doesn't really matter as long as it does what it's expected to do.

f0dder wrote:
scientica wrote:

well, I'm no expert on posix, but, afaik it only defines a baseline of C functions and structs (eg, open(), read(), close()), many "gnu" apps has a --posix wich i makes it act posixly, ie killing any extensions.

Hm, I thought posix also defined memory mapped files and threads? If it doesn't even have that... eek.

I don't know but I think POSIX (at least the most recent versions) should define mmap() et al, also, given that iirc pthreads is "posix threads", well catually "NPTL" (Native POSIX Thread Layer, iirc), the new threading model in linux.

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 14 Aug 2006, 12:44
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
scientica wrote:

One down side of prelinking is that it in effect voids PIC/PIE, the best it does is randomize the Entry Point (if explicity told)

PIC/PIE?

Anyway, reading the "as-needed" article makes me think that ELF (or perhaps not ELF itself, but the way it's used in linux) has a long way to go. And people talk about "DLL hell" on windows? >_<.


scientica wrote:

For "local" X sessions a unix socket is used (think of it as a socket that really isn't running over a network but a IPC-like-thingy-shortcut).

ah, nice enough - at least that cuts away some IP related overhead.


scientica wrote:

In all honestly, I actaully liked NT4 and Win2k, and I stand by that Win2k was the last windows I found usable

XP is nice once you apply www.nliteos.com ... the kernel has had a few updates since 2k (not THAT much, XP vs 2k is NT5.1 vs NT5.0), and there's a bit more hardware support etc. out of the box.


scientica wrote:

Well, I think a pre installed linux or windows is just the same for a "normal user", ie, if all it does is check mail, surf, write text doucments/spreadhseets.

It's similar enough, a lot of the time. As long as everything works. As long as they don't have to drop into a shell. As long as there's no compatibility problems (office documents, etc.)

I know linux just wouldn't work at the museum. They have a few special-needs apps, every once in a while some office document they receive wouldn't work in openoffice, they'd get REALLY confused about the new filesystem layout, and the small-but-existing differences in user interfaces, et cetera.
Post 15 Aug 2006, 11:28
View user's profile Send private message Visit poster's website Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica
PIC/PIE = Position Independant Code/PIC Exceutabble, in short it makes the app run with a different Entry Point every time it runs, improves security a litte, marginal slow down.
Post 16 Aug 2006, 04:47
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Ah, I thought PIC referred to that, but got confused about mixing this up with security... it's more about not requring a relocation table, and (because of relocation fixups) causing dirty-pages etc.

It does mean that all global variable access needs the addition of a delta-register, which makes opcodes a bit longer (but of course if you use only a few global variables, you can use the fact that EBP+bytedisplacement encodes pretty small).

Oh well Smile
Post 16 Aug 2006, 08:17
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.