New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

Operating Systems

by: Mireya Heidenreich

Operating Systems CS 3733

Mireya Heidenreich
GPA 3.55

Steven Robbins

Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Steven Robbins
Class Notes
25 ?




Popular in Course

Popular in ComputerScienence

This 3 page Class Notes was uploaded by Mireya Heidenreich on Thursday October 29, 2015. The Class Notes belongs to CS 3733 at University of Texas at San Antonio taught by Steven Robbins in Fall. Since its upload, it has received 10 views. For similar materials see /class/231380/cs-3733-university-of-texas-at-san-antonio in ComputerScienence at University of Texas at San Antonio.

Similar to CS 3733 at UTSA

Popular in ComputerScienence


Reviews for Operating Systems


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 10/29/15
91 302 Chapter 9 Times and Timers POSIX Times POSIX speci es that systems should keep time in terms of seconds since the Epoch and that each day be accounted for by exactly 86400 seconds The Epoch is de ned as 0000 midnight January 1 1970 Coordinated Universal Time also called UTC Greenwich Mean Time or GMT POSIX does not specify how an implementation should align its system time with the actual time and date Most operations need to be measured with timers with greater than onesecond resolu tion Two POSIX extensions the POSIXXSI Extension and the POSIXTMR Extension de ne time 39 39 of 39 39 and 39 39 39 r Expressing time in seconds since the Epoch The POSIX base standard supports only a time resolution of seconds and expresses time since the Epoch using a timeit type which is usually implemented as a long A program can access the system time expressed in seconds since the Epoch by calling the time function If tloc is not NULL the time function also stores the time in thC SYIVOPSIS include lttime hgt timeit timetime7t tloc POSIX CX If successful t ime returns the number of seconds since the Epoch If unsuccessful t ime returns timeit 71 POSIX does not de ne any mandatory errors for time D Exercise 91 The timeit type is usually implemented as a long Ifa long is 32 bits at ap proximately what date would timeit over ow Remember that one bit is used for the sign What date would cause an over ow if an unsigned long were used What date would cause an over ow if a 64bit data type were used Answer For a 32bit long time would over ow in approximately 68 years from January 1 1970 so the system would not have a Y2K problem until the year 2038 For a timeit value that is an unsigned long the over ow would occur in the year 2106 but this would not allow time to return an error For a 64bit data type the over ow would not occur for another 292 billion years long after the sun has died The diff t ime function computes the difference between two calendar times of type timeit making it convenient for calculations involving time The difftime function 91 POSIX Times 303 has two timeit parameters and returns a double containing the rst parameter minus the second SYIVOPSIS include lttime hgt double difftimekimeit timel timeit timeO POSIX CX No errors are de ned for difftime I Example 92 The following program calculates the wallclock time that it takes to execute functionitoitime include ltstdiohgt include lttimehgt void functionitoitime void int mainvoid timeit tstart tstart timeN ULL functionitoitime U printfquotfunctionitoitime took at seconds of elapsed timenquot difftime time NULL tstart return 0 simpletiming c Example 92 uses a time resolution of one second which may not be accurate enough unless f unctionitoitime involves substantial computation or waiting Also the time function measures wallclock or elapsed time which may not meaningfully re ect the amount of CPU time used Section 915 presents alternative methods of timing code Displaying date and time The timeit type is convenient for calculations requiring the difference between times but it is cumbersome for printing dates Also a program should adjust dates and times to account for factors such as time zone daylightsaving time and leap seconds The localtime function takes a parameter specifying the seconds since the Epoch and returns a structure with the components of the time such as day month and year adjusted for local requirements The asctime function converts the structure returned by localtime to a string The Ctime function is equivalent to asctime localtime clock The gmtime function takes a parameter representing seconds since the Epoch and returns a structure with the components of time eXpressed as Coordinated Universal Time UTC 304 Chapter 9 Times and Timers SYIVOPSIS include lttime hgt char asctimeconst struct tm timeptr char ctimeconst timeit clock struct tm gmtimeconst timeit timer struct tm localtimeconst timeit timer POSIX CX No errors are de ned for these functions The Ctime function takes one parameter a pointer to a variable of type timeit and returns a pointer to a 26character Englishlanguage string The Ctime function takes into account both the time zone and daylight saving time Each of the elds in the string has a constant width The string might be stored as follows Sun Oct 06 022135 1986n0 I Example 93 The following program prints the date and time The printf format did not include n39 because Ctime returns a string that ends in a newline include ltstdiohgt include lttimehgt int mainVoid i it tcurrent tcurrent time NULL printfquotThe current time is as ctimeamptcurrent return 0 Exercise 94 What is wrong with the following program that prints the time before and after the function funct i omit oft ime executes include ltstdiohgt include lttime hgt Void functionitoitime Void int mainVoid t meit tend tstart tstart timeN39ULL tend time NULL printfquotThe time before was sThe time after was as ctime amptstart ctime amptend return 0


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Janice Dongeun University of Washington

"I used the money I made selling my notes & study guides to pay for spring break in Olympia, Washington...which was Sweet!"

Steve Martinelli UC Los Angeles

"There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."


"Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.