This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 int i = 0; | |
114 int received = 0; | |
115 int sizenow = 4096; | |
116 int sizebefore = sizenow; | |
117 char *buffer = (char *) malloc(sizenow); | |
118 char *buf = buffer; | |
119 while ((received = read(sock, buf, 4096))>0) | |
120 { | |
121 i = i + received; | |
122 sizebefore = sizenow; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 static bool | |
51 pack_str(struct whackpacker *wp, char **p) | |
52 { | |
53 const char *s = *p == NULL? "" : *p; /* note: NULL becomes ""! */ | |
54 size_t len = strlen(s) + 1; | |
55 | |
56 if (wp->str_roof - wp->str_next < (ptrdiff_t)len) | |
57 { | |
58 return FALSE; /* fishy: no end found */ | |
59 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct whack_message msg; | |
struct whackpacker wp; | |
//где whackpaker имеет вид: | |
struct whackpacker { | |
struct whack_message *msg; | |
unsigned char *str_roof; | |
unsigned char *str_next; | |
int n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# IPsec startup and shutdown script | |
# | |
### BEGIN INIT INFO | |
# Provides: ipsec | |
# Required-Start: $network $remote_fs $syslog $named | |
# Required-Stop: $syslog $remote_fs | |
# Default-Start: | |
# Default-Stop: 0 1 6 | |
# Short-Description: Start Openswan IPsec at boot time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent; | |
public class Ex2q1fix { | |
private static class Peterson { | |
private final AtomicIntegerArray flag = new AtomicIntegerArray(2); | |
public volatile int victim; | |
public void lock() throws InterruptedException { | |
System.out.println("Aquiring lock for thread with id=" + threadLocalId.get()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Peterson { | |
public volatile boolean[] flag = new boolean[2]; | |
public volatile int victim; | |
public void lock() { | |
int i = Integer.parseInt(Thread.currentThread().getName().substring(7)) - 1; | |
int j = 1 - i; | |
flag[j] = true; | |
victim = i; | |
while (flag[j] && victim == i) {}; // wait | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//package mpp; | |
import java.util.concurrent.locks.Lock; | |
import java.util.concurrent.locks.ReentrantLock; | |
public class Ex2q1 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//package mcp; | |
public class outpit { | |
static int counter = 0; | |
public static void main(String[] args) throws InterruptedException { | |
if (args.length < 1) { | |
throw new IllegalArgumentException("Usage: Ex1q9 N"); | |
} | |
Integer numberOfThreads = Integer.valueOf(args[0]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class myE { | |
static int counter = 0; | |
public static void main(String[] args) throws InterruptedException { | |
if (args.length < 1) { | |
throw new IllegalArgumentException("Usage: Ex1q9 N"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 class Bouncer f | |
2 public static nal int DOWN = 0; | |
3 public static nal int RIGHT = 1; | |
4 public static nal int STOP = 2; | |
5 private boolean goRight = false; | |
6 private ThreadLocal<Integer> myIndex; | |
7 private int last = 1; | |
8 int visit () f | |
9 int i = myIndex.get(); | |
10 last = i; |
NewerOlder