課程名稱︰系統程式
課程性質︰系必修
課程教師︰施吉昇
開課學院:電資學院
開課系所︰資工系
考試日期(年月日)︰2010.6.23
考試時限(分鐘):180
是否需發放獎勵金:是
(如未明確表示,則不予發放)
試題 :
Final exam for Spring 2010, System Programming
--------------------------------------------------------------------------
--------------------------------------------------------------------------
Some function prototypes you may need:
int setjmp(jmp_buf env);
void longjmp(jmp_buf env, int val);
int sigemptyset(sigset_t *set);
int sigfillset(sigset_t *set);
int sigaddset(sigset_t *set, int signo);
int sigdelset(sigset_t *set, int signo);
int sigprocmask(int how, const sigset_t *set, sigset_t *oset);
how:SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK
int sigpending(sigset_t *set);
int sigaction(int signo, const struct sigaction *act
, struct sigaction *oact);
struct sigaction{
void (*sa_handler)(int); //func addr, SIG_IGN, or SIG_DFL
sigset_t sa_mask; //additional signals to block
int sa_flags; //just set it to be SA_INTERRUPT
void(*sa_sigaction)(int,siginfo_t*, void *);//alternate handler
};
int sigsuspend(const sigset_t *sigmask);
int pipe(int filedes[2]);
pid_t fork(void);
int dup2(int filedes, int filedes2);
int execv(const char *pathname, char *const argv[]);
pid_t wait(int *statloc);
void(*signal(int signo, void (*func)(int)))(int);
unsigned int alarm(unsigned int seconds);
------------------------------------------------------------------------------
Page 12 of 12
Mid-term exam for Spring 2010, System Programming
------------------------------------------------------------------------------
char *fgets(char *s, int n, FILE *stream);
FILE *fopen(const char*file, const char *mode);
int open(const char *file, const char *mode);
int close(int fd);
ssize_t read(int filedes, coid *buf, size_t nbytes);
ssize_t write(int filedes, const void *buf, size_t nbytes);
int fclose(FILE *stream);
int fflush(FILE *stream);
int fileno(FILE *stream);
char *tmpnam(char *ptr);
FILE *tmpfile(void);
int dup(int filedes);
int fup2(int filedes, int filedes2);
int fsync(void);
int fdatasync(int filedes);
void sync(void);
mode_t umask(mode_t cmask);
int stat(const char *restrict pathname, struct stat *restrict buf);
int fstat(int filedes, struct stat *buf);
int lstat(const char*restrict pathname, struct stat *restrict buf);
DIR *opendir(const char *pathname);
struct dirent *readdir(DIR *dp);
void rewinddir(DIR *dp);
int closedir(DIR *dp);
long telldir(DIR *dp);
void seekdir(DIR *dp, long loc);
closedir(dp);
struct passwd *getpwent(void);
void setpwent(void);
void endpwent(void);
struct passwd *getpwuid(uid_t uid);
struct passwd *getpqnam(const char *name);
struct group *getgrgid(gid_t gid);
struct group *getgrnam(const char *name);
int link(const char *existingpath, const chat *newpath);
int unlink(const char *pathname);
ssize_t readlink(const char* restrict pathname, char *restrict buf, size_t bufsize);
int symlink(const char *actralpath, const char *sympath);
struct dirent{
ino_t d_ino; /* i-node number */
char d_name[NAME_MAX+1]; /* null-terminated filename */
}
struct stat{
mode_t st_mode; /* file type & mode(permissions) */
ino_t st_ino; /* i-node number(serial number) */
dev_t st_dev; /* device number(file system) */
-----------------------------------------------------------------------------
Page 10 of 11
-----------------------------------------------------------------------------
dev_t st_rdev; /* device number for special files */
nlink_t st_nlink; /* number of links */
uid_t st_uid; /* user ID of owner */
gid_t st_gid; /* group ID of owner */
off_t st_size; /* size in bytes, for regular files */
time_t st_atime; /* time of last access */
time_t st_mtine; /* time of last modification */
time_t st_ctime; /* time of last file status change */
blksize_t st_blksize; /* best I/O block size */
blkcnt_t st)blocks; /* number of disk blocks allocated */
};
struct passwd{
char *pw_name;
char *pw_passwd;
uid_t pw)uid;
gid_t pw_gid;
char *pw_gecos;
char *pw_dir;
char *pw_shell;
};
struct group{
char *gr_name; /* group name */
char *gr_passwd; /* group password */
gid_t gr_gid; /* group ID */
char **gr_mem; /* group members */
};
------------------------------------------------------------------------------
Page 11 of 11
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.91.122