Wikipedia:Reference desk/Archives/Computing/2013 May 19
Computing desk | ||
---|---|---|
< May 18 | << Apr | May | Jun >> | May 20 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
May 19
editWhere to find material for shared library programming?
editIn section Memory sharing of article Shared libraries, it mentioned "... shared code must be specifically written to run in a multitasking environment ...". It seems code designed for shared libraries should follow certain programming rules which are different from normal application programming. Probably (I have no idea) global variables for shared libraries need to be specially protected or functions need to be reentrant like designing kernel module ... stuff like that.
I've google'd for a while for it. Most what I've found are about ELF format, shared library compilation, ... but not what I need in programming aspects. So does anyone knows where to find the related information if any? -- Justin545 (talk) 00:42, 19 May 2013 (UTC)
- That article is a bit obscurely written, and I think perhaps you've misunderstood it. In real life, very few shared libraries involve multiple programs using the same chunk of memory at the same time (as the "Memory sharing" section describes). The usual case is that each program linking to a library gets its own private runtime copy of the code for the library functions that it uses. Thus in the ordinary case there are no particular requirements concerning multitasking. Looie496 (talk) 02:29, 19 May 2013 (UTC)
- So, for example, the shared library (.so) has the code:
int gVar = 5;
int shLibFunc(int arg)
{
gVar = gVar * arg;
return gVar;
}
- and the first program linking to the shared library has the code:
int main()
{
shLibFunc(3);
printf("1st program: gVar=%d\n", gVar);
return 0;
}
- and the second program linking to the shared library has the code:
int main()
{
shLibFunc(-8);
printf("2nd program: gVar=%d\n", gVar);
return 0;
}
- Then the output of the first program will be:
1st program: gVar=15
- and the output of the seconde program will be:
2nd program: gVar=-40
- the behavior will like this way? (each program has its own copy of data segment which will be initialized appropriately) -- Justin545 (talk) 11:28, 19 May 2013 (UTC)
- Yes that's what'll happen by default. Dmcq (talk) 12:39, 19 May 2013 (UTC)
- the behavior will like this way? (each program has its own copy of data segment which will be initialized appropriately) -- Justin545 (talk) 11:28, 19 May 2013 (UTC)
- I agree with you, the section is pretty much misleading. Thanks for the quick answer. -- Justin545 (talk) 18:43, 19 May 2013 (UTC)
- When a DLL (on windows) or .so (on Unix/Linux/etc.) is imported, the loader creates a custom .data segment in the memory map of the application, copies in the relevant data initialisers, and invokes any necessary initialisers (C) and constructors (C++). From a programmer's perspective, there's no substantive difference between such a dynamic link and a static link; programs which link the same .dll/.so are independent, and global variables and the like behave the same whether there are one or more than one instances of the shared object present in the system. Only if the shared library does something deliberately inter-process (creates files, named pipes, etc., uses IPC objects like doors or shared memory, or on Windows manipulates the global atom table) will the difference be apparent - and this is true whether or not the IPC stuff is done in an application's own code or in a shared library's. So if you write a library as just that - a library of calls that anyone can call, with no system-global state, then there is essentially nothing different to do. But some libraries do decide they need system global state; that's not necessarily a wrong thing to do, but it means the library is performing a service, rather than just being a bunch of code for others to call. If a library wanted to do that, it would be doing IPC (so it might create a shmem block or something) - it wouldn't happen by accident. And managing that state, as with all issues of global state, can get a bit complicated. I'm guessing that the caveats in the article (I agree with Looie496 that the wording is obtuse and unhelpful) are to do with this. An important concern is that even loading a library can invoke code (which is often desirable when using shared objects in this way): on Windows the system invokes the DLL's DllMain() function, and similar behaviour can be performed on Unix thus:
void __attribute__ ((constructor)) so_load (void);
void so_load (void) { // this is called when the library is loaded, implicitly or by dlopen
// do global initialisation here, akin to DllMain
}
- I'm not aware of any restrictions on what this code can do (there's similar destructor code too) on Unix (et al); on Windows (because of the rather complicated way library loading is synchronised) there are all kinds of things that are dangerous to do in a DllMain(), as described in this document. -- Finlay McWalterჷTalk 12:44, 19 May 2013 (UTC)
- Thanks for M$ stuff about DLLs. They should probably give me something more about shared libraries.
- As you mentioned "But some libraries do decide they need system global state; that's not necessarily a wrong thing to do, but it means the library is performing a service, rather than just being a bunch of code for others to call."
- So what did you mean the library is performing a service? As far as I know "services" are usually provided by daemons or server processes (e.g. crond, sshd, dbus-daemon, XServer) which are all "running" programs. So how can a shared library together with the system global state provide service? I'm quite insterested... -- Justin545 (talk) 18:43, 19 May 2013 (UTC)
Current method I'm using to remove redlink entries in a set of lists - need faster method
editI'm removing superfluous redlinks from country outlines.
To remove the redlinks of "Political scandals of foo" (where foo is a country name) from each country outline, I take a list of country outlines (on a user subpage) and replace "Outline of" with "Political scandals of". That list now shows which links are red.
Then I use AWB's listmaker to make a list of all the redlinks on that page, and I paste them back in to the same page and linkify them. Now there's only redlinks on that page.
Next I change "Political scandals of" back to "Outline of". The list is now all the country outlines that contain the "Political scandals of" redlink in them.
I make a list in AWB from that, and then do a regex search/replace with AWB to get rid of the entry in each of those outlines.
Unfortunately, I have to do this whole procedure over again for each redlink I wish to nuke (so as not to nuke the blue links too), and this approach only works with sets of links that share the "of foo" nomenclature. Because AWB has no way to search/replace strings based on redlink status (as far as I know).
If you know of a easier/faster way to do this, please let me know...
Please post replies to Wikipedia:Bot requests/Archive 55#Current method I'm using to remove redlink entries in a set of lists - need faster method. Thank you. The Transhumanist 06:42, 19 May 2013 (UTC)
Game making...
editHey guys! I somewhat recently realized how fun point-and-click games can be; this genre is something I never really considered before but now I'm inspired. Usually, I'd whip up something on The Games Factory (1.06 - the one from the 90s) but the installer for that is unobtainable now so I couldn't move it to my laptop and run it in compatibility mode. So, does anyone know the best way for me to make my own point-and-click adventure games? Freeware is preferable but I'll hear out anyone's paid suggestions. Thanks! --Yellow1996 (talk) 17:02, 19 May 2013 (UTC)
- You might try Adventure Game Studio. An example video of a game produced with it is here (I'd recommend you turn the volume off). -- Finlay McWalterჷTalk 17:18, 19 May 2013 (UTC)
- Wow! Adventure Game Studio looks awesome! Thanks, Finlay! :) (And, about Scratch - I've used it before and found it a little too limited, ;) but thanks for the prompt suggestion, Gilderien.) --Yellow1996 (talk) 17:27, 19 May 2013 (UTC)
- btw, if you're just getting into this genre, and you can find it, I heartily recommend Day of the Tentacle -- Finlay McWalterჷTalk 18:10, 19 May 2013 (UTC)
- Looks fun! I'm generally lucky when it comes to finding older games; I guess we'll have to see... --Yellow1996 (talk) 01:22, 20 May 2013 (UTC)
- IMHO Full Throttle and Grim Fandango were pinnacles of the genre. Vespine (talk) 03:55, 20 May 2013 (UTC)
- Looks fun! I'm generally lucky when it comes to finding older games; I guess we'll have to see... --Yellow1996 (talk) 01:22, 20 May 2013 (UTC)
- MIT Scratch is a graphical programming language created for beginners that I recommend. Also see Alice. Tarcil (talk) 01:50, 21 May 2013 (UTC)
Spambot question
editI was reading a Finnish on-line forum when I noticed that a new user had replied to several threads, all in Finnish. The first was a reply to a thread about jokes, and the message said basically "Thanks, this made me laugh". But then I read a reply to a thread about on-line dating, where the user had replied to a woman, saying "I still suggest you create a test profile for yourself", when the thread had made it clear she already had. This caught my attention, and I soon discovered that the user had copy-pasted random sentences from previous messages in the threads, verbatim. The user's signature had links to on-line video game cheating sites. This confirmed my suspicion that the user was a spambot. It had tried to be clever by copy-pasting messages in Finnish it had found on the forum instead of trying to write in English. Unfortunately, neither the spambot or any of its programmers apparently understand any Finnish. Is this a new phenomenon or has it already been found on several on-line forums? JIP | Talk 18:28, 19 May 2013 (UTC)
- I've never encountered this, but I must say it is a step up from the days of "Cool!" followed by a whole bunch of spam links. --Yellow1996 (talk) 01:24, 20 May 2013 (UTC)
- My blog occasionally gets comments from people saying things like "yes I agree" followed by a link to a dating site or something. I assumed it was some sort of spambot too so I've been deleting and blocking the commenters. Vespine (talk) 03:52, 20 May 2013 (UTC)
- This picture (currently used at Forum spam) is a good example of the generic comment plus spam link tactic. --Yellow1996 (talk) 18:43, 20 May 2013 (UTC)
Google translate worse now?
editIs it just me, or has google translate become worse recently (last year or so)? Perhaps they changed their code? Having problems with words that are capitalized (e.g. in languages without capitalization) and German umlauts sometimes appear as "ae", etc. instead of "ä", and generally very often it does not find translations of words at all. For some closely related languages it used to be much better as far as I remember. bamse (talk) 21:04, 19 May 2013 (UTC)
- It is not just you. I have noticed this as well; translations of webpages used to be a lot more comprehensible but now they aren't that great. Also for individual words they often - as you noted - can't find a translation at all. The quality of the translations can be seen through a fun test: type in a word or phrase. Then, translate it to your language of choice. Then, copy+paste the result back into the input box and reverse the translation. Did you get what you started with? Probably not; and if you keep doing it back and forth, chances are the translation will get further and further from what you initially put in until it hits a certain result that won't change. It can produce some funny results, but it shows the poor quality of certain translations. :) --Yellow1996 (talk) 01:31, 20 May 2013 (UTC)
- Well you can get very strange things happening if you translate people's names - they're probably trying to bias their translators to be more careful about that. I wonder too whether they mightn't be using translated rubbish from themselves or other automatic translators to update the translations, i.e. reinforcing the gibberishness. Dmcq (talk) 09:42, 20 May 2013 (UTC)
Citrix weirdness
editHi:
I find that from the same computer, I am able to use the Windows version of Citrix client to connect to my Citrix server at work, but not the Linux version of the Citrix client, where I would get a "The SOCKS 5 handshake failed (SSL error 29)." error. I have changed my computer into a DMZ computer so that all ports are open (I have googled that the SOCKS 5 error could be related to port 1494 not open), but to no avail. Also thinking about it rationally if it is really related to ports shouldn't both Windows and Linux Citrix client be affected? Any insight into this is appreciated! Thanks.
Some specs:
Computer: Pentium 4 Prescott core
Windows: XP
Linux: Slackware 14.0
174.94.46.146 (talk) 21:12, 19 May 2013 (UTC)
- DMZ might guarantee all ports are open to the machine, but not necessarily to the application. Do you know you don't have a firewall running on your slackware install? Try something like this or this to check if the required ports are actually open. Vespine (talk) 06:00, 20 May 2013 (UTC)