Changeset 52e4f52 in mainline for uspace/srv/bd/rd/rd.c


Ignore:
Timestamp:
2009-06-23T18:19:56Z (15 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d4b9d28
Parents:
ed990cf
Message:

Use rwlock instead of futex for ramdisk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/rd/rd.c

    red990cf r52e4f52  
    5151#include <align.h>
    5252#include <async.h>
    53 #include <futex.h>
     53#include <fibril_sync.h>
    5454#include <stdio.h>
    5555#include <devmap.h>
     
    6464
    6565/**
    66  * This futex protects the ramdisk's data.
     66 * This rwlock protects the ramdisk's data.
    6767 * If we were to serve multiple requests (read + write or several writes)
    6868 * concurrently (i.e. from two or more threads), each read and write needs to be
    69  * protected by this futex.
     69 * protected by this rwlock.
    7070 */
    71 atomic_t rd_futex = FUTEX_INITIALIZER;
     71fibril_rwlock_t rd_lock;
    7272
    7373/** Handle one connection to ramdisk.
     
    140140                                break;
    141141                        }
    142                         futex_down(&rd_futex);
     142                        fibril_rwlock_read_lock(&rd_lock);
    143143                        memcpy(fs_va, rd_addr + offset * block_size, block_size);
    144                         futex_up(&rd_futex);
     144                        fibril_rwlock_read_unlock(&rd_lock);
    145145                        retval = EOK;
    146146                        break;
     
    162162                                break;
    163163                        }
    164                         futex_up(&rd_futex);
     164                        fibril_rwlock_write_lock(&rd_lock);
    165165                        memcpy(rd_addr + offset * block_size, fs_va, block_size);
    166                         futex_down(&rd_futex);
     166                        fibril_rwlock_write_unlock(&rd_lock);
    167167                        retval = EOK;
    168168                        break;
     
    217217                return false;
    218218        }
     219
     220        fibril_rwlock_initialize(&rd_lock);
    219221       
    220222        return true;
Note: See TracChangeset for help on using the changeset viewer.