[Linux] Process--Memo

Source: Internet
Author: User

1,sigpipe signal:

When writing a socket program under Linux , if you try to send to a disconnected socket, you will let the underlying throw a sigpipe signal. The default approach to this signal is to exit the process, which is not what we expect most of the time. Therefore, we need to overload this signal processing method. You can safely mask sigpipeby calling the following code:

TCP/IP four-way wave click to open link

2,prctl () function application
http://blog.csdn.net/zuokong/article/details/7318154
For example, returning the process that is currently calling the function
Char threadname[17]; One more for termination
if (Prctl (Pr_get_name, (unsigned long) threadname, 0, 0, 0)! = 0) {
strcpy (ThreadName, "<name unknown>");


3, write data to the socket often encounter EINTR error ~ should be ignored
#define RETRY_ON_EINTR (Ret,cond) \
do {\
ret = (cond); \
} while (Ret < 0 && errno = = eintr)

RETRY_ON_EINTR (ret, write (s, &tid, sizeof (unsigned)));

4, Spin lock in single-core and multi-core differences

1. In a single CPU, cannot preempt the kernel, the spin lock is an empty operation.
2. In a single CPU, can preempt the kernel, the spin lock is implemented as "Prohibit kernel preemption", does not implement "spin".
3. In multi-CPU, can preempt the kernel, the spin lock is implemented as "Prohibit kernel preemption" + "spin".

5,android command to view memory Procrank command ~

      • VSS -Virtual Set Size virtualized memory consumption (contains memory consumed by shared libraries)
      • RSS -resident Set Size actually uses physical memory (contains memory consumed by shared libraries)
      • PSS -Proportional Set Size actual physical memory used (proportional allocation of memory consumed by shared libraries)
      • USS -Unique Set Size process consumes physical memory alone (does not contain memory consumed by shared libraries)

[Linux] Process--Memo

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.