[Zz] ubiquitous context switch

Source: Internet
Author: User

Sometimes the computer suddenly slows down. When you open the "Task Manager", you will be surprised to find that there are so many inexplicable "resident programs" being executed at the same time? One of the culprit programs occupies nearly of the CPU performance. It's no wonder that your Visual Studio suddenly becomes so slow.

Not only do computers have a lot of resident programs, but they will interrupt our important programs. In our real life, there are also many routine and non-routine tasks that occupy a large part of our day, it makes our work inefficient. It may be a boring meeting without a conclusion, a phone call from a girlfriend, a meaningless greeting on MSN, a courtesy greeting from the partner, or a ticket from the administrative staff. difficult. This will reduce your productivity.

You know, except for all these messy things, you can definitely save a lot of time writing programs, so you don't need to work overtime every day! However, you may not know the time you save, not only the time of these chores, but also the time for "entering the stream.

Psychologists have discovered a mental state of "high concentration and high productivity", called flow ). It takes about 15 minutes (0.25 hours) to enter the stream status. You can
The "Enter stream" time is equivalent to the overhead when the CPU uses context-switch.

More than two decades ago, the book peopleware: productive projects and teams began to remind us how much damage a programmer has to productivity when writing a program due to external interference. All in all, if you want to improve your program productivity, you can fully view the context-switches in a day and try to avoid them.

Assume that there is a programmer who has one hour of rest at noon and 3.5 hours of work every afternoon. Then, when he is in high productivity, it is about 3.5-0.25 + 3.5-0.25 = 6.5 hours. Assume that the phone calls and other chores are interrupted for 10 times in a day, and every time it takes 6 minutes (0.1 hours), the time for high productivity will change to 6.5-(0.1 + 0.25) * 10 = 3 hours. The reduction was astonishing. 6 + 15 = 21 minutes of interruption.

It takes 15 minutes for each shift to return to the previous stream. Therefore, it is difficult for most programmers to have high productivity at work during the day. Many programmers like to write programs at night (or after work), because midnight interference is much less than daytime interference, so the production capacity is relatively high.

How can programmers avoid interference from the office? Most programmers have no independent offices and only small blocks, so it is difficult to avoid interference. When I used to work, I often dreamed of adding a partition in the office block to the height, covering the roof, and adding a sliding door to become an "office box" of 1.5x1.5x2 cubic meters 」. I also want to add a chimney with a breathable effect. If there is an office box, it should be able to block a lot of interference from the office.

Many programmers are used to wearing headphones when they go to work. When the ears become predictable (such as music), the brain can turn it into white noise and actively filter it out. However, I think wearing headphones all day will make my ears uncomfortable. In addition, the long-term use of headphones will cause hearing loss, while modern medicine believes that hearing loss cannot be restored, so wearing headphones does not seem to be a good practice. I tried to use ear plug later and thought the effect was good.

Instant Messenger (IM) software often causes interference in work. I try not to enable IM or set it to busy at work. Some people are very white-eyed, ignoring my "busy" status and asking me for unimportant conversations. Such people will be blocked by me. In addition to im, phones are often the source of interference.

The above interference can be easily noticed, but there is a type of interference that is caused by programming languages and development tools, and also causes context-switch, reducing the productivity of programmers, but few noticed it.

Some programming languages and development tools require you to perform self-testing, debugging, compilation, and linking lengthy actions to let you leave a truly productive stream. Most of these languages are compiled, low-level, and traditional languages.

The script language obviously does not have this problem. Many people who use the script language will feel highly productive, and the development time can be many times faster than traditional languages. On the one hand, it is because
The script language is very advanced and can be used with relatively short code to do a lot of things. On the other hand, you can modify it immediately if you have any problems and leave the "stream" without interrupting it 」.

Even in traditional languages, you can use development tools to reduce the amount of data that leaves the stream and improve the development efficiency. For example, intellij before year 67 is obviously less context-switch than other Java ides at that time, with higher productivity, so it will soon become one of the most popular Java ides.

Note: Some behaviors are easily mistaken for interference, but they actually contribute to productivity. For example, if you are tired, you can get up and move around and buy coffee in Starbucks outside the office, but keep your mind in the original context and continue to think about it. Do not use context-switch. When the body is moving, the blood circulation accelerates, and the brain seems clearer.

When walking, do not be distracted by things along the road, or talk to others, because these will cause context-switch. But you have to be careful, because I have been shopping for coffee several times, so I was almost hit by a car! To avoid context switch, host damage is not worthwhile.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.