As of 2016-02-26, there will be no more posts for this blog. s/blog/pba/
Showing posts with label sleep. Show all posts


This post is for GNU/Linux and POSIX systems.

Its quite often when I work on an old ANSI C/C89 code, if its using usleep and -Wall, then there would be a warning:

warning: implicit declaration of function 'usleep'

Since GNU C Library 2.12 (May 2010), you need to have right macros to have it, see usleep(3). I think the better way is to move onto nanosleep if its for POSIX systems, and every time I would have to copy from previous modified code. I think I will make a note for it.

1   usleep


2   nanosleep

#define _POSIX_C_SOURCE       199309L

#include <time.h>

struct timespec req = {
  .tv_sec = SLEEP / 1000000,
  .tv_nsec = SLEEP * 1000

nanosleep(&req, NULL);

Note that if SLEEP is for less than a second, then you can directly set .tv_sec to 0. Also _POSIX_C_SOURCE >= 199309L is required.

Starting showering twice a day is the only thing I am happy with myself this summer. I used to shower at evening, but this summer something have inspired me, I should have done this before. Now I shower after and before sleep. After the before-sleeping shower, I also drink a small cup of warm tea to prepare my night. Those help me relax.

It makes me feel really good after the morning shower, my body would be completely awaken, fresh, and clean. A cup of coffee follows up, wow! it can't be better than that. I wish I could have done this when I was a student, I might have better performance at morning classes.

I also thought a shower/bathing was a minimum for personal hygiene, but some pages I read from googling they didn't say so. However, they didn't have references. Some else said it's okay if you feel necessary, and I did feel that way. I am not that kind of guy stays in bathroom longer ten minutes nor a neat freak.

There is one thing for sure, I use more water than before. At least, I didn't cause global warming anymore. I started to shower in cold water, I used to use hot water no matter how hot the day is. Showing with cold water feels really good, I had heard some people claimed it's better for your health, I didn't dare to try. Thanks to the water heater, I got my chance.

I don't think I can shower twice in winter, every time I turned off the hot water at shower in winter, it begins a bloody battle between me and time. I have to dress as quick as I can, or I would shake like a nuts.

If you only do once day, then try one more a day, you will like it!