242 User Area

The role of the user area (traditionally referred to as the uarea), has changed somewhat in the Solaris environment when compared with traditional implementations of UNIX. The uarea was linked to the proc structure through a pointer and thus was a separate data structure. The uarea was swappable if the process was not executing and memory space was tight. Today, thearea is embedded in the process structure. The process kernel stack, which was traditionally maintained in the uarea, is now implemented in the LWP (seeSection 2.4.3).

typedef struct user{

* These fields are initialized at process creation time and never

* modified. They can be accessed without acquiring locks.

struct execsw *u_execsw; /* pointer to exec switch entry */

auxv_t u_auxv[_KERN_NAUXV_IMPL]; /* aux vector from exec */

timestruc_t u_start; /* hrestime at process start */

char u_comm[MAXCOMLEN + 1]; /* executable file name from exec */

char u_psargs[PSARGSZ]; /* arguments from exec */

uintptr_t u_argv; /* value of argv passed to main() */

uintptr_t u_envp; /* value of envp passed to main() */

See usr/src/uts/common/sys/user.h

The uarea fields shown above are self-explanatory and align with the standard application binary interface (ABI) in terms of maintaining objects set in the process image when loaded. These variables store the command, argument list from the command line, and the user's environmental variablesshell variables, such as PATH, TERM, HOME, etc.

The uarea is where process open file information is maintained, referenced through theuarea's u_finfo variable. This variable is a data structure, uf_info_t, which establishes the base for a list of open files in the process.

* Per-process file information.

typedef struct ufjnfo {

kmutex_t fi_pad; /* unused - remove in next release */

int fi_nfiles; /* number of entries in fi_list[] */

uf_entry_t 'volatile fi_list; /* current file list */

uf_rlist_t *fi_rlist; /* retired file lists */ } uf_info_t;

See usr/src/uts/common/sys/user.h

The list of open files begins with fi_list, which is an array of file entry structures of the typeuf_entry_t, and is indexed by the file descriptora numeric value returned from a successful open(2) system call.

typedef struct uf_entry {

kmutex_t ufjock; /* per-fd lock [never copied] */ struct file *uf_file; /* file pointer [grow, fork] */ struct fpollinfo *uf_fpollinfo; /* poll state [grow] */ int uf_refcnt; /* LWPs accessing this file [grow] */

int uf_alloc; /* right subtree allocs [grow, fork] */

short uf_flag; /* fcntl F_GETFD flags [grow, fork] */ short uf_busy; /* file is allocated [grow, fork] */ kcondvar_t uf_wanted_cv; /* waiting for setf() [never copied] */ kcondvar_t uf_closing_cv; /* waiting for close() [never copied] */ struct portfd *uf_portfd; /* associated with port [grow] */ /* Avoid false sharing - pad to coherency granularity (64 bytes) */ char uf_pad[64 - sizeof (kmutex_t) - 2 * sizeof (void*) -2 * sizeof (int) - 2 * sizeof (short) -2 * sizeof (kcondvar_t) - sizeof (struct portfd *)]; } uf_entry_t;

See usr/src/uts/common/sys/user.h

The uf_file entry points to the file structure associated with the file.

typedef struct file {

kmutex_t f_tlock; /* short term lock */ ushort_t f_flag;

ushort_t f_pad; /* Explicit pad to 4-byte boundary */ struct vnode *f_vnode; /* pointer to vnode structure */ offset_t f_offset; /* read/write character pointer */ struct cred *f_cred; /* credentials of user who opened it */ struct f_audit_data *f_audit_data; /* file audit data */ int f_count; /* reference count */

See usr/src/uts/common/sys/file.h

Within the file structure, we find a link to the vnode (f_vnode), which contains the file-system-specific object that defines the file. For example, for a file in UFS, the file's inode is found through the vnode and contains the information necessary to locate the body of the file (see Section 14.2 and Section 15.3 for further information).

The links to a process's open file list are shown in Figure 2.5.

0 0

Post a comment

  • Receive news updates via email from this site