Simple UDP Server in Kernel-space
Web Server in kernel-space
在這兩個例子可以看到如何在kernel裡撰寫網路程式以及如何使用kernel thread
cat -n test.txt | sort -k 2 -n -u | sort -k 1 -n | cut -f 2Bash (by FourDollars)
#!/usr/bin/env bashPerl (by OuTian)
declare -a db
declare -i index=0
cat file.txt | while read line; do
if ! echo ${db[*]} | grep $line > /dev/null; then
db[$((index++))]="$line"
echo "$line"
fi
done
cat test.txt | perl -ne 'print unless($s{$_}++)'C (by HZYSoft)
> /* File: remove_dup.c: Remove duplicated string in a file.
Author: PCMan (C) 2008.02.08
License: GNU GPL V2 */
#include <stdio.h< #include > stdlib.h < #include > string.h int main( int argc, char** argv ) {
int i, j, n, buf_size = 1024;
char **strv, line[1024];
FILE *f;
if( ! (f = fopen( argv[1], "r" )) ) return 1;
strv = (char**)malloc(buf_size * sizeof(char*) );
for( n = 0; fgets( line, sizeof(line), f ); ++n ) {
if( n >= buf_size ) {
buf_size += 1024;
strv = (char**)realloc( strv, buf_size );
}
strv[n] = strdup( line );
}
fclose(f);
for( i = 0; i < n; ++i ) {
for( j = i + 1; j < n; ) {
if( 0 == strcmp( strv[i], strv[j] ) ) {
free( strv[j] );
#ifdef KEEP_ORDER /* 如果保持原有順序 */
memcpy( &strv[j], &strv[j+1], sizeof(char*) * (n-j-1) );
#else /* 如果不管順序,這樣速度會快很多 */
strv[j] = strv[n - 1];
#endif
--n;
}
else {
++j;
}
}
}
if( ! (f = fopen( argv[1], "w" )) ) return 1;
for( i = 0; i < n; ++i ) {
fputs( strv[i], f );
free( strv[i] );
}
fclose( f );
return 0;
}
Edmund M. Clarke, E. Allen Emerson, and Joseph Sifakis are the recipients of the 2007 A.M. Turing Award for their work on an automated method for finding design errors in computer hardware and software.
The method, called Model Checking, is the most widely used technique for detecting and diagnosing errors in complex hardware and software design. It has helped to improve the reliability of complex computer chips, systems and networks.