Changeset 10d6b858 in mainline


Ignore:
Timestamp:
2008-01-06T16:40:58Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
222e57c
Parents:
4db6eaf
Message:

Introduce the open file lock. Modify vfs_rdwr() to take this lock into account
when reading or writing from/to an open file.

Location:
uspace/srv/vfs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs.h

    r4db6eaf r10d6b858  
    148148 */
    149149typedef struct {
     150        /** Serializes access to this open file. */
     151        futex_t lock;
     152
    150153        vfs_node_t *node;
    151154       
  • uspace/srv/vfs/vfs_file.c

    r4db6eaf r10d6b858  
    8787                                return ENOMEM;
    8888                        memset(files[i], 0, sizeof(vfs_file_t));
     89                        futex_initialize(&files[i]->lock, 1);
    8990                        vfs_file_addref(files[i]);
    9091                        return i;
  • uspace/srv/vfs/vfs_rdwr.c

    r4db6eaf r10d6b858  
    8383
    8484        /*
     85         * Lock the open file structure so that no other thread can manipulate
     86         * the same open file at a time.
     87         */
     88        futex_down(&file->lock);
     89
     90        /*
    8591         * Lock the file's node so that no other client can read/write to it at
    8692         * the same time.
     
    127133
    128134        /*
    129          * Update the position pointer.
     135         * Update the position pointer and unlock the open file.
    130136         */
    131137        file->pos += bytes;
     138        futex_up(&file->lock);
    132139
    133140        /*
Note: See TracChangeset for help on using the changeset viewer.