Multiprocesses & shared library question

This is a discussion on Multiprocesses & shared library question within the C Programming forums, part of the General Programming Boards category; Hey So I'm sorta getting the idea of multiple processes but now I encounter a theory problem. So I want ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    192

    Multiprocesses & shared library question

    Hey So I'm sorta getting the idea of multiple processes but now I encounter a theory problem.
    So I want to do 3 processes. one parent and 2 child of that one parent. So the child are going to use this library code thats basically makes a linklist or data repository. The question i have is that since both the child are seperate processes and they both access the library that creates a linklist. Does this end up making 2 link list for each one of the child or do they share the memory and share the data respository leaving only one link list in the whole project.


    If this does create 2 link list since I'm not really sure how linux does its memory management, what possible solutions are there to share a library with the 2 child processes that making only 1 data respository instead of two

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by kiros88 View Post
    If this does create 2 link list since I'm not really sure how linux does its memory management, what possible solutions are there to share a library with the 2 child processes that making only 1 data respository instead of two
    Using fork() you will end up with two lists. Using pthreads() you could access the same list, but of course pthreads() is much more work.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    192
    so does linux besides using pthreads have any way of making a library a shared library data respository

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Separate processes are a good idea if the processes do not need to share data. If data sharing is a requirement, threads is probably a better idea.
    bit∙hub [bit-huhb] n. A source and destination for information.

  5. #5
    Maz
    Maz is offline
    Registered User Maz's Avatar
    Join Date
    Nov 2005
    Location
    Finland
    Posts
    194
    "any way of making a library a shared library data respository"...

    Sorry, but I do not really understand your terms here It is probably my fault, since I am not native english speaker. If you mean data sharing between running processes, then yes. You can use shared memory, which can be accessed from multiple processes.

    If you mean how library linking is done, then linux offers 2 possibilities, static *.a libraries, which will be linked statically into binary, and shared libraries (*.so), which can be linked at runtime. *.so libraries are not needed to be loaded on physical ram more than once, since MMU can map the *.so lib (which resides in only one place at physical memory) multiple times in different locations on virtual memory - satisfying the needs of multiple processes without wasting physical ram.

    I am not sure if I answered to correct question though

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem in changing shared library path in linux
    By remyasj in forum Linux Programming
    Replies: 3
    Last Post: 08-06-2009, 08:31 AM
  2. shared library for QNX
    By ReeV in forum C Programming
    Replies: 3
    Last Post: 05-06-2009, 10:58 AM
  3. library question max(val, 255)
    By tms43 in forum C++ Programming
    Replies: 7
    Last Post: 09-10-2007, 06:22 AM
  4. wxWidgets loading shared library problem
    By BobS0327 in forum Linux Programming
    Replies: 1
    Last Post: 05-10-2006, 07:23 PM
  5. n00b question regarding the Map Class in the STL library
    By Axegrinder#9 in forum C++ Programming
    Replies: 2
    Last Post: 12-17-2005, 08:40 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21