LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-25-2006, 11:21 AM   #16
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45

> aluser has very eloquently provided what would seem to be the definitive reply.
i would agree with that.

ahem. i have reread the posts from the beginning and, i suppose i was unclear in my original post.

> stack memory access is faster than heap memory.

saying access was wrong, what i (intended) should have said was using the stack will be faster than using heap. that would possibly fit better with the points i have made above.
 
Old 08-25-2006, 12:53 PM   #17
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,610
Blog Entries: 4

Rep: Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905Reputation: 3905
Quote:
Originally Posted by aral
1.What is the difference between the acces time for a process to acces a shared memory segment and the acces time for a process to access its own local memory on a Linux system? As far as I know the access time for a process to a shared memory segment is miliseconds, is that right ? if yes then what's the access time for a process to acces its own local memory ?

2.Is it faster , at run time, to use the simple functions for Posix shared memory(like shm_open )wrapped around a class instead of using a stuffy shared memory library like boostshmem ? If yes , then is the difference considerably faster or not ?
The "access time" of memory depends upon locality of reference, which is the base assumption that drives the virtual memory system, viz: "The next memory address requested by this program is probably close to one of the recent memory addresses requested by this program." The virtual memory system tries to identify the current working set of pages needed by this process, keeping recently-used pages instantly available and allowing older pages to gradually disappear from the process's working-set.

What you are trying to avoid in all cases is a page fault,, where the page you need isn't in real-memory and the virtual memory system has to go out to disk (or whereever) and get it.

It really doesn't matter how the page came to be part of your working set. Shared memory and non-shared memory wind up the same way and perform the same way.

The working-set phenomenon favors memory access-methods that tend to exhibit locality-of-reference. For example, singly-linked lists aren't very efficient: you might concievably page-fault on every single step. A tree or hash-table structure that kept its own small pool of MRU (most-recently-used) nodes would be very efficient, because it could zero-in on the desired data with a minimum of memory references.

In designing your system, I simply recommend simplicity and clarity over excessive obsession with "speed." After all, if you write something "very clever" and then spend three or four hours debugging it ... that's 14.4 billion microseconds of potential computer time (and valuable hair!) wasted.
 
Old 08-25-2006, 01:34 PM   #18
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
sundialsvcs, you seem to have a good understanding of the process. What you describe in your first paragraph sounds like an optimization mechanism. Is this typically performed wholley by the MMU, or is there a OS kernel level involvement (ie CPU code) in the scheme?

--- rod.
 
Old 08-25-2006, 01:47 PM   #19
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
Quote:
In designing your system, I simply recommend simplicity and clarity over excessive obsession with "speed." After all, if you write something "very clever" and then spend three or four hours debugging it ... that's 14.4 billion microseconds of potential computer time (and valuable hair!) wasted.
yeh. thats probably the best advice in the whole thread.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
controlling time and memory psmech Programming 6 07-25-2006 12:44 AM
acces windows share from my linux box jb_jauvin Slackware 6 03-30-2005 08:00 PM
Can I acces my Linux box from anywhere in tyhe world??? MR_UNO Linux - Networking 3 12-01-2004 11:28 AM
Invalid memory acces while booting kernel Rookie12 Linux - Newbie 0 10-14-2004 07:38 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration