Sie sind auf Seite 1von 2

Operating Systems HW Assignment #4 In this assignment, you will have to extend/refa tor the !

logging system" you have developed in the assignment ## to in lude some additional features$ %he new logging system will support &oth file and ''()&ased logging with relevant fun tionality pa *ed into +,,s$ -$ (irst, you have to develop two +,,s with the same set of exported fun tions &ut with a &it different fun tionality$ %he +,,s . alled mmf/log$dll and file/log$dll0 should implement fun tions for logging using ''( and dis* file storage respe tively$ %he +,,s will exported following fun tions1 ,HA2+,3 Start,ogging .,45%S%6 log/name, +WO6+ dw,ogSi7e, +WO6+ dw%imeout0 a$ %his fun tion will &e used &y writers and readers to initiali7e ''( or (ile)&ased log file &$ ,HA2+,3 is #8 &it value .typedef ,49OI+ ,HA2+,30 that represents the log instan e $ :se .,HA2+,30)- return value to for an error d$ dw%imeout to use for all syn hroni7ations waits 9OI+ Stop,ogging.,HA2+,3 h,og0 a$ %his fun tion is used &y writers and the viewer to stop logging and to free all unneeded resour es .handles, memory ,files0 &$ A epts handle to a log file previously o&tained from Start,ogging fun tion +WO6+ Write,og3ntry.,HA2+,3 h,og0 a$ %his fun tion is used &y writers to write a log entry &$ 6eturns a se;uen e num&er of su essfully written log entry <OO, 4op,og3ntry.,HA2+,3 h,og,,O=/32%6>? p,og3ntry0 a$ %his fun tion is used &y the viewer to read log entry &$ If there is no log entries, the fun tion should return false .does not wait if log file is empty0 $ ,O=/32%6> is defined as stru t @+WO6+ dw%imeA+WO6+ dwSB2A +WO6+ dw4I+, +WO6+ dwSumC HA2+,3 =et,ogWaitO&De t.,HA2+,3 h,og0 a$ %his fun tion is used &y the viewer pro ess to o&tain a handle for a win#8 waita&le o&De t .e$g$ semaphore0 that is signaled when there are log entries in the log file

8$ A pro ess .e$g$ writer pro ess0 should load one of these +,,s a&ove at run time depending on the ommand line argument it re eives$ In order to ma*e it easy for all future developers to use this fun tionality, you will need to wrap the +,, loading pro ess into another +,, .g/log$dll0 whi h will &e lin*ed to exe uta&les using ompile time &inding$ %his !generali7ed log" +,, should export following set of fun tions1

=,HA2+,3 =,Start,ogging . ,45%S%6 log/name, +WO6+ dw,ogSi7e, +WO6+ dw%imeout, <OO, &:se''(0 9OI+ =,Stop,ogging.=,HA2+,3 h,og0 +WO6+ =,Write,og3ntry.=,HA2+,3 h,og0 <OO, =,4op,og3ntry.=,HA2+,3 h,og,,O=/32%6>? p,og3ntry0 HA2+,3 =,=et,ogWaitO&De t.=,HA2+,3 h,og0 #$ %he exported fun tions of g/log$dll are very similar to fun tions of mmf/log$dll and file/log$dll $ 4lease noti e that =,Start,ogging has additional parameter for spe ifying log file type .''()&ased or file &ased0 $ Also note that a different type name .typedef ,49OI+ =,HA2+,30 is used for a log file handle 4$ In this assignment, the log file is identified &y a single string .log/name0 whi h is interpreted as a name of a dis* file or a name of a file mapping o&De t$ If you need more o&De t names .e$g$ mutex or ontrol file name0, you an derive them from log/name &y string manipulations .e$g$ adding suffix " /mutex" or extensions e$g$ !$ ontrol"0 E$ 4ass -F as log file si7e parameter in the su&mitted ode$ However, during the de&ugging try different values$ G$ +efine stru t inside your +,,s to represent file/''()&ased log file and a general log file$ 5ast pointers to these stru tHs &a * and forth from/to ,HA2+,3/=,HA2+,3 as needed I$ (rom writers/viewer use dire tly g/log$dll only$ Hide within g/log$dll all the omplexity asso iated with run)time +,, loading$ 'a*e sure your system wor*s when only needed +,, is present .e$g$ delete file/log$dll and run test with ''( log file0 J$ %ry to write your +,,s ode in a way that will allow simultaneous usage of several different log files from a single pro ess .e$g$ no glo&al varia&les0$ K$ ,ogWriter/,og9iewer/,og%est should a ept same ommand line arguments and return same exit odes as in assignment ## with following two hanges1 the name of the log file might not &e a path &ut an ar&itrary string .in ase of ''( file0$ Instead of path to a ontrol file, there will &e <oolean value to represent type of a log file to use .- L''(, F)file0$ -F$ %ry to run several sessions simultaneous &y running several ,og%est with different file types and log names$ Happy Programming

Das könnte Ihnen auch gefallen