Shared-memory between threads and synchronization .

Discussion in 'Linux Networking' started by bobby, Mar 7, 2007.

  1. bobby

    bobby Guest

    Hi everyone,
    In my project i am having different data structures
    which should have access only for some classes and the structures i
    had declared globally, but then i need a restricted access so thought
    of using shared memory. The whole project is executed as a single
    process and shared memory should be accessed between different
    threads. The synchronization i need to provide obviously through
    mutexes. So my questions are--

    1. Is the idea better to implement shared memory rather than
    declaring data structures global?
    2. I need to even use signals for transferring the control, is it
    feasible?
    3. If a thread locked by a mutex and executing a critical section,
    and if time-slice for that particular light-
    weight process completes at that very
    moment, will the thread hold the mutex or according to the time-slice
    the OS skips the thread and executes other thread?
    4. In any case a "struct sched_param param.sched_priority" need to
    be set for particular threads, based on priority or can we manage
    synchronization with mutexes itself?

    Kindly
    answer my querries..

    Thanx in advance......

    Bobby.
     
    bobby, Mar 7, 2007
    #1
    1. Advertisements

  2. Your questions reflect such a large lack of basic threading knowledge
    that you would do better to read some basic books or web pages on
    threading and then come back when you can ask better questions.

    All threads have precisely the same view of memory. So when you talk
    about shared memory with threads as an option -- there is no other
    option!

    You seem to have some very basic misconceptions about scheduling
    versus synchronization. They are basically unrelated except in some
    very limited special cases (such as priority inversion).

    Your question about signals doesn't seem to make any sense at all. You
    nakedly assert that you "need to use signals", but it's nearly certain
    that you don't need to. (Signals are not useful for transferring
    control, though it's not clear what you mean by "transferring
    control".

    You manage synchronization with synchronization primitives such as
    mutexes. But why do you ask that in association with scheduling
    policy?

    DS
     
    David Schwartz, Mar 8, 2007
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.