Changeset 337 for trunk/kernel/vfs


Ignore:
Timestamp:
Aug 7, 2017, 12:50:17 PM (7 years ago)
Author:
alain
Message:

Introduce the delayed context switch if current thread has a lock.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/vfs/vfs.c

    r333 r337  
    4040#include <mapper.h>
    4141#include <thread.h>
     42#include <chdev.h>
    4243#include <process.h>
    4344#include <vfs.h>
     
    5253//////////////////////////////////////////////////////////////////////////////////////////
    5354
    54 extern vfs_ctx_t   fs_context[FS_TYPES_NR];    // allocated in kernel_init.c
    55 
     55extern vfs_ctx_t          fs_context[FS_TYPES_NR];    // allocated in kernel_init.c
     56
     57extern chdev_directory_t  chdev_dir;                  // allocated in kernel_init.c 
    5658 
    5759//////////////////////////////////////////////////////////////////////////////////////////
     
    534536    file->attr     = attr;
    535537    file->offset   = 0;
    536     file->refcount = 0;
     538    file->refcount = 1;
    537539    file->inode    = inode;
    538540    file->ctx      = inode->ctx;
     
    10531055//////////////////////////////////////////////////////////////////////////
    10541056// This static function is called by the vfs_display() function.
     1057// that is supposed to take the TXT0 lock.
    10551058//////////////////////////////////////////////////////////////////////////
    10561059static void vfs_recursive_display( xptr_t   inode_xp,
     
    11041107
    11051108    // display inode
    1106     printk("%s%s <%s> inode_xp = %l / dentry_xp = %l\n",
    1107            indent_str[indent], vfs_inode_type_str( inode_type ),
    1108            name , inode_xp , dentry_xp );
     1109    nolock_printk("%s%s <%s> inode_xp = %l / dentry_xp = %l\n",
     1110                  indent_str[indent], vfs_inode_type_str( inode_type ),
     1111                  name , inode_xp , dentry_xp );
    11091112
    11101113    // scan directory entries 
     
    11551158    cxy_t          dentry_cxy;
    11561159    vfs_dentry_t * dentry_ptr;
     1160    uint32_t       save_sr;
    11571161
    11581162    // get target inode cluster and local pointer
     
    11791183    }
    11801184
     1185    // get pointers on TXT0 chdev
     1186    xptr_t    txt0_xp  = chdev_dir.txt[0];
     1187    cxy_t     txt0_cxy = GET_CXY( txt0_xp );
     1188    chdev_t * txt0_ptr = GET_PTR( txt0_xp );
     1189
     1190    // get extended pointer on remote TXT0 chdev lock
     1191    xptr_t  lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock );
     1192
     1193    // get TXT0 lock in busy waiting mode
     1194    remote_spinlock_lock_busy( lock_xp , &save_sr );
     1195
    11811196    // print header
    1182     printk("\n*** VFS ***\n");
     1197    nolock_printk("\n***** file system state\n");
    11831198
    11841199    // call recursive function
    11851200    vfs_recursive_display( inode_xp , name_xp , dentry_xp , 0 );
     1201
     1202    // release lock
     1203    remote_spinlock_unlock_busy( lock_xp , save_sr );
    11861204
    11871205}  // end vfs_display()
Note: See TracChangeset for help on using the changeset viewer.