Process thread

Use select system call is: within a specified period of time, the file descriptor of interest to monitor user-readable, write and abnormal events can
distinguish and mutex semaphore (the mutex): The mutex allows only thread enters a critical section, the semaphore allows multiple threads to enter the critical section.
Critical resource: exclusive resource, read and write the same area code storage space.

Zombie processes: when a child process exits, the parent process does not process it, resulting in the child stays in zombie state waiting for its parent corpses ..
how to deal with a zombie: When the parent process exits, zombie processes change layer orphaned, will adoptee orphan process management system process, and clean up.
the critical area: access critical resources snippets

The nature of the semaphore counter is
standard concepts: Process Synchronization is a direct relationship between the constraints of the process, two or more threads to accomplish a task and established this thread need to coordinate their work order and in some locations wait passing restrictive relationship information generated. Directly restricts the relationship between the process comes from the cooperation between them.
Semaphore between processes: one id can simultaneously operate a plurality of semaphores, a signal is not limited to addition and subtraction
signals between threads: 1 on a semaphore id, a value of the acceleration can only signal


Can wait thread: a thread exits, the main thread must accept his return code, otherwise occupied resources are not released, adjustable pthread_join accepted
from the thread is the main thread to ignore the return value

Thread is a function of execution, function parameters can transmit data to achieve

Difference between TCP and UDP:
a transmission control protocol, there are links, reliable byte stream data loss retransmission mechanism
2 datagram protocol, no link is unreliable packet transmission, and can achieve broadcast and multicast, retransmission of lost may be implemented at the application layer.

There are weak links: to accept data through a descriptor
no link Unicast: sometimes will be spam
-free link broadcast: send the whole subnet broadcast
without much broadcast link: join the multicast group receives multicast data

Heartbeat mechanism:
int Life;
the while (. 1) // main thread
{
the sendto (OK);
SLEEP (. 5);
LIFE -;
IF (Life <0)
the puts ( "error")
}

while(1)
{

recv();
if(buffer =="ok")
{
life++;
}
}

while(1)
{

recv(sock,buf);
if(buffer == "ok")
{
sed("ok")
}
}

 

Computer networking process:
1 broadcasts its MAC computer
2 switches recording mac, and broadcast to all ports
3 discarded ignoring other computers
4 distributed router IP, DNS, MASK, GATEWAY information
5 switches forward the message to port
6 of the computer receives the DHCP data, set the card information

Log QQ
. 1 the login message -> wifi-> Router
2 Router analysis target ip and port
3 with port assigned by the router protocol NET, alternatively with internet LAN source address and port address, and send the data record
4 data receiving router, NET lookup table, the replace the LAN destination port address and port -> computer

 


memcpy(void *dest,void *src,int count)
{
if(dest == NULL|| src==NULL)
{
return NULL;

}

char* pdest = (char*)dest;
char* pscr = (char*)src;
while(count--)
{
*pdest = *psrc;
}
return dest;
}

Guess you like

Origin www.cnblogs.com/countryboy666/p/10982935.html