forked from mit-pdos/xv6-public
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathshmtest.c
146 lines (141 loc) · 18.9 KB
/
shmtest.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include "types.h"
#include "stat.h"
#include "user.h"
int number = 123456;
char *hello = "hello m";
char *child = "y child!";
char *content = "0123456789this is content from offset 10,art, eventually winning by a considerable margin to record their second consecutive victory, and taking the overall record in the Women's Boat Race to 43–30 in their favour. The men's race was the final event of the day and completed a whitewash as Cambridge won, their second victory in three years, and taking the overall record to 83–80 in their favour. The races were watched by around a quarter of a million spectators live, and were broadcast around the world by a variety of broadcasters. The two main races were also available for the second time as a live stream using YouTube.\
In the Rhine Campaign of 1796 (nominated by auntieruth) ), two First Coalition armies under the overall command of Archduke Charles outmaneuvered and defeated two French Republican armies. This was the last campaign of the War of the First Coalition, part of the French Revolutionary Wars.\
The Flora of Madagascar (nominated by Tylototriton) consists of more than 12,000 species of vascular and non-vascular plants and a poorly known number of fungi. Around 83% of Madagascar's vascular plants are only found on the island. These endemics include five plant families, 85% of the over 900 orchid species, around 200 species of palms, and such emblematic species as the traveller's tree, six species of baobab and the Madagascar periwinkle. The high degree of endemism is due to Madagascar's long isolation since its separation from the African and Indian landmasses in the Mesozoic, 150–160 and 84–91 million years ago, respectively. However, few plant lineages remain from the ancient Gondwanan flora; most extant plant groups immigrated via across-ocean dispersal well after continental break-up.\
John Mowbray, 3rd Duke of Norfolk (nominated by Serial Number 54129) was a fifteenth-century English magnate who, despite having a relatively short political career, played a significant role in the early years of the Wars of the Roses.\
Central Link (nominated by SounderBruce) is a light rail line in Seattle, Washington, United States, and part of Sound Transit's Link light rail system. It serves 16 stations in the cities of Seattle, SeaTac, and Tukwila, traveling 20 miles (32 km) between University of Washington and Angle Lake stations. The line connects the University District, Downtown Seattle, the Rainier Valley, and Seattle–Tacoma International Airport. Central Link carried over 23 million total passengers in 2017, with an average of 72,000 daily passengers on weekdays.\
The Ford Piquette Avenue Plant (nominated by Jackdude101) is a former factory located within the Milwaukee Junction area of Detroit, Michigan, in the United States. Built in 1904, it was the second center of automobile production for the Ford Motor Company, after the Ford Mack Avenue Plant. At the Piquette Avenue Plant, the company created and first produced the Ford Model T, the car credited with initiating the mass use of automobiles in the United States. It was also the first factory where more than 100 cars were assembled in one day. While it was headquartered at the Piquette Avenue Plant, Ford Motor Company became the biggest US-based automaker, and it would remain so until the mid-1920s. The factory was used by the company until 1910.\
Simon Hatley (nominated by Wehwalt) was an English sailor involved in two hazardous privateering voyages to the South Pacific Ocean. On the second voyage, with his ship beset by storms south of Cape Horn, Hatley shot an albatross, an incident immortalised by Samuel Taylor Coleridge in his poem, The Rime of the Ancient Mariner.\
Sonic X-treme (nominated by Red Phoenix) was a platform game developed by Sega Technical Institute from 1994 until its cancellation in 1997. X-treme was intended to be the first fully 3D Sonic the Hedgehog game and the first original Sonic game for the Sega Saturn. Its concepts built on past Sonic games while introducing elements to take Sonic into the 3D era of video games. The storyline followed Sonic on his journey to stop Dr. Robotnik stealing six magic rings from Tiara Boobowski and her father.\
The 2007 AT&T 250 (nominated by Laser brain) was a NASCAR Busch Series stock car race that took place on June 23, 2007. Held at the Milwaukee Mile in West Allis, Wisconsin, the race was the 17th of 35 in the 2007 NASCAR Busch Series season. Aric Almirola of Joe Gibbs Racing (JGR) was the listed winner of the race, Richard Childress Racing's Scott Wimmer finished second, and Braun Racing's Jason Leffler finished third.\
Mark XIV bomb sight (nominated by Laser brain), a bombsight developed by Royal Air Force (RAF) Bomber Command during the Second World War. Production of a slightly modified version was also undertaken in the United States as the Sperry T-1, which was interchangeable with UK-built version.\
Messier 87 (nominated by AhmadLX) is a supergiant elliptical galaxy in the constellation Virgo. One of the most massive galaxies in the local Universe, it is notable for its large population of globular clusters—about 12,000 compared to the 150–200 orbiting the Milky Way—and its jet of energetic plasma that originates at the core and extends at least 1,500 parsecs (4,900 light-years), travelling at relativistic speed. It is one of the brightest radio sources in the sky, and a popular target for both amateur and professional astronomers.\
SMS Braunschweig (nominated by Parsecboy) was the first of five pre-dreadnought battleships of the Braunschweig class built for the German Kaiserliche Marine(Imperial Navy). She was launched in December 1902. She was named after the Duchy of Brunswick (German: Braunschweig). Like all other pre-dreadnoughts built at the turn of the century, Braunschweig was quickly made obsolete by the launching of the revolutionary HMS Dreadnought in 1906; as a result, her career as a front-line battleship was cut short.\
The cooperative pulling paradigm (nominated by Edwininlondon) is used by ethologists, comparative psychologists, and evolutionary psychologists try to understand how cooperation works and how and when it may have evolved. Two or more animals pull rewards towards themselves via an apparatus that they can not successfully operate alone. Chimpanzees, bonobos, orangutans, capuchins, tamarins, wolves, elephants, ravens, and keas appear to understand the requirements of the task. The conclusions regarding cooperation are mixed and complex.\
The First Battle of Dernancourt (nominated by Peacemaker67) was fought on 28 March 1918 near Dernancourt in northern France during World War I. It involved a force of the German 2nd Army attacking elements of the VII Corps, which included British and Australian troops, and resulted in a complete defeat of the German assault.\
The Socialist Soviet Republic of Abkhazia (nominated by Kaiser matias) was a short-lived republic within the Caucasus region of the Soviet Union that covered the territory of Abkhazia, and existed from 31 March 1921 to 19 February 1931. Formed in the aftermath of the Red Army invasion of Georgia in 1921, it was independent until 16 December 1921, when it agreed to a treaty uniting it with the Georgian Soviet Socialist Republic (Georgian SSR). The SSR Abkhazia was largely similar to an autonomous Soviet republic, though it retained de facto independence from Georgia, being given certain features only full union republics had, like its own military units. Through its status as a \"treaty republic\" with Georgia, Abkhazia joined the Transcaucasian Soviet Federative Socialist Republic, which united Armenian, Azerbaijani, and Georgian SSRs into one federal unit, when the latter was formed in 1922. The SSR Abkhazia was abolished in 1931 and replaced with the Abkhaz Autonomous Soviet Socialist Republic within the Georgian SSR.ad from the start, eventually winning by a considerable margin to record their second consecutive victory, and taking the overall record in the Women's Boat Race to 43–30 in their favour. The men's race was the final event of the day and completed a whitewash as Cambridge won, their second victory in three years, and taking the overall record to 83–80 in their favour. The races were watched by around a quarter of a million spectators live, and were broadcast around the world by a variety of broadcasters. The two main races were also available for the second time as a live stream using YouTube.\
In the Rhine Campaign of 1796 (nominated by auntieruth) ), two First Coalition armies under the overall command of Archduke Charles outmaneuvered and defeated two French Republican armies. This was the last campaign of the War of the First Coalition, part of the French Revolutionary Wars.\
The Flora of Madagascar (nominated by Tylototriton) consists of more than 12,000 species of vascular and non-vascular plants and a poorly known number of fungi. Around 83% of Madagascar's vascular plants are only found on the island. These endemics include five plant families, 85% of the over 900 orchid species, around 200 species of palms, and such emblematic species as the traveller's tree, six species of baobab and the Madagascar periwinkle. The high degree of endemism is due to Madagascar's long isolation since its separation from the African and Indian landmasses in the Mesozoic, 150–160 and 84–91 million years ago, respectively. However, few plant lineages remain from the ancient Gondwanan flora; most extant plant groups immigrated via across-ocean dispersal well after continental break-up.\
John Mowbray, 3rd Duke of Norfolk (nominated by Serial Number 54129) was a fifteenth-century English magnate who, despite having a relatively short political career, played a significant role in the early years of the Wars of the Roses.\
Central Link (nominated by SounderBruce) is a light rail line in Seattle, Washington, United States, and part of Sound Transit's Link light rail system. It serves 16 stations in the cities of Seattle, SeaTac, and Tukwila, traveling 20 miles (32 km) between University of Washington and Angle Lake stations. The line connects the University District, Downtown Seattle, the Rainier Valley, and Seattle–Tacoma International Airport. Central Link carried over 23 million total passengers in 2017, with an average of 72,000 daily passengers on weekdays.\
The Ford Piquette Avenue Plant (nominated by Jackdude101) is a former factory located within the Milwaukee Junction area of Detroit, Michigan, in the United States. Built in 1904, it was the second center of automobile production for the Ford Motor Company, after the Ford Mack Avenue Plant. At the Piquette Avenue Plant, the company created and first produced the Ford Model T, the car credited with initiating the mass use of automobiles in the United States. It was also the first factory where more than 100 cars were assembled in one day. While it was headquartered at the Piquette Avenue Plant, Ford Motor Company became the biggest US-based automaker, and it would remain so until the mid-1920s. The factory was used by the company until 1910.\
Simon Hatley (nominated by Wehwalt) was an English sailor involved in two hazardous privateering voyages to the South Pacific Ocean. On the second voyage, with his ship beset by storms south of Cape Horn, Hatley shot an albatross, an incident immortalised by Samuel Taylor Coleridge in his poem, The Rime of the Ancient Mariner.\
Sonic X-treme (nominated by Red Phoenix) was a platform game developed by Sega Technical Institute from 1994 until its cancellation in 1997. X-treme was intended to be the first fully 3D Sonic the Hedgehog game and the first original Sonic game for the Sega Saturn. Its concepts built on past Sonic games while introducing elements to take Sonic into the 3D era of video games. The storyline followed Sonic on his journey to stop Dr. Robotnik stealing six magic rings from Tiara Boobowski and her father.\
The 2007 AT&T 250 (nominated by Laser brain) was a NASCAR Busch Series stock car race that took place on June 23, 2007. Held at the Milwaukee Mile in West Allis, Wisconsin, the race was the 17th of 35 in the 2007 NASCAR Busch Series season. Aric Almirola of Joe Gibbs Racing (JGR) was the listed winner of the race, Richard Childress Racing's Scott Wimmer finished second, and Braun Racing's Jason Leffler finished third.\
Mark XIV bomb sight (nominated by Laser brain), a bombsight developed by Royal Air Force (RAF) Bomber Command during the Second World War. Production of a slightly modified version was also undertaken in the United States as the Sperry T-1, which was interchangeable with UK-built version.\
Messier 87 (nominated by AhmadLX) is a supergiant elliptical galaxy in the constellation Virgo. One of the most massive galaxies in the local Universe, it is notable for its large population of globular clusters—about 12,000 compared to the 150–200 orbiting the Milky Way—and its jet of energetic plasma that originates at the core and extends at least 1,500 parsecs (4,900 light-years), travelling at relativistic speed. It is one of the brightest radio sources in the sky, and a popular target for both amateur and professional astronomers.\
SMS Braunschweig (nominated by Parsecboy) was the first of five pre-dreadnought battleships of the Braunschweig class built for the German Kaiserliche Marine(Imperial Navy). She was launched in December 1902. She was named after the Duchy of Brunswick (German: Braunschweig). Like all other pre-dreadnoughts built at the turn of the century, Braunschweig was quickly made obsolete by the launching of the revolutionary HMS Dreadnought in 1906; as a result, her career as a front-line battleship was cut short.\
The cooperative pulling paradigm (nominated by Edwininlondon) is used by ethologists, comparative psychologists, and evolutionary psychologists try to understand how cooperation works and how and when it may have evolved. Two or more animals pull rewards towards themselves via an apparatus that they can not successfully operate alone. Chimpanzees, bonobos, orangutans, capuchins, tamarins, wolves, elephants, ravens, and keas appear to understand the requirements of the task. The conclusions regarding cooperation are mixed and complex.\
The First Battle of Dernancourt (nominated by Peacemaker67) was fought on 28 March 1918 near Dernancourt in northern France during World War I. It involved a force of the German 2nd Army attacking elements of the VII Corps, which included British and Australian troops, and resulted in a complete defeat of the German assault.\
The Socialist Soviet Republic of Abkhazia (nominated by Kaiser matias) was a short-lived republic within the Caucasus region of the Soviet Union that covered the territory of Abkhazia, and existed from 31 March 1921 to 19 February 1931. Formed in the aftermath of the Red Army invasion of Georgia in 1921, it was independent until 16 December 1921, when it agreed to a treaty uniting it with the Georgian Soviet Socialist Republic (Georgian SSR). The SSR Abkhazia was largely similar to an autonomous Soviet republic, though it retained de facto independence from Georgia, being given certain features only full union republics had, like its own military units. Through its status as a \"treaty republic\" with Georgia, Abkhazia joined the Transcaucasian Soviet Federative Socialist Republic, which united Armenian, Azerbaijani, and Georgian SSRs into one federal unit, when the latter was formed in 1922. The SSR Abkhazia was abolished in 1931 and replaced with the Abkhaz Autonomous Soviet Socialist Republic within the Georgian SSR.";
int sig = 23333333;
int sig2 = 1531534;
int sig3 = 78945;
int main()
{
printf(1, "================================\n");
printf(1, "Memory sharing test started.\n");
if (createshm(sig, 16000, 0) >= 0 && createshm(sig2, 40, 0) >= 0 && createshm(sig3, 50, 1) >= 0)
printf(1, "[P] Share memory created.\n");
else
{
printf(1, "[P] Share memory creating failed.\n");
exit();
}
printf(1, "[P] Writing message to child...\n");
if (writeshm(sig, content, 15476, 0) == -1 || writeshm(sig2, hello, 7, 0) == -1 || writeshm(sig2, child, 9, 7) == -1)
{
printf(1, "Error!\n");
exit();
}
printf(1, "[P] Forking child...\n");
if (fork() == 0) // This is child.
{
printf(1, "[C] Receiving message from parent...\n");
char *read = malloc(16000);
char *read2 = malloc(16);
createshm(sig, 0, 0);
createshm(sig2, 0, 0);
if (readshm(sig, read, 15475, 10) == -1 || readshm(sig2, read2, 16, 0))
{
printf(1, "Error!\n");
free(read);
free(read2);
exit();
}
read[30] = '\0';
printf(1, "[C] First 30 characters received by child in sig %d: \n", sig);
printf(1, "[C] %s", read);
printf(1, "\n");
printf(1, "[C] Full string received by child from parent in sig %d: \n", sig2);
printf(1, "[C] %s", read2);
printf(1, "\n");
printf(1, "[C] Forking grandchild...\n");
if (fork() == 0) // This is child2
{
createshm(sig3, 0, 1);
printf(1, "[G] Writing message to parent parallely with child...\n");
char *hellogp = "good morning grandpa! ";
writeshm(sig3, hellogp, 22, 0);
exit();
}
else
{
createshm(sig3, 0, 1);
printf(1, "[C] Writing message to parent parallely with grandchild...\n");
char *helloparent = "hello my parent!";
writeshm(sig2, helloparent, 17, 2);
char *inter = (char *)&number;
writeshm(sig2, inter, 4, 20);
char *hellop = "good morning father!";
writeshm(sig3, hellop, 21, 22);
free(read);
free(read2);
wait();
exit();
}
}
else // This is parent.
{
wait();
int *urec = 0;
char *tmp = malloc(5);
char *rec = malloc(17);
char *parch = malloc(50);
if (readshm(sig2, rec, 17, 2) == -1 || readshm(sig2, tmp, 4, 20) == -1 ||readshm(sig3, parch, 43, 0) == -1)
{
printf(1, "Error!\n");
free(rec);
free(tmp);
free(parch);
exit();
}
printf(1, "[P] Full string received by parent from child in sig %d: \n", sig2);
printf(1, "[P] %s", rec);
printf(1, "\n");
printf(1, "[P] Integer received by parent from child in sig %d: \n", sig2);
urec = (int *)tmp;
printf(1, "[P] %d\n", *urec);
printf(1, "[P] String received by parent from child and grandchild in sig %d: \n", sig3);
printf(1, "[P] %s", parch);
printf(1, "\n");
free(rec);
free(tmp);
free(parch);
}
if (deleteshm(sig) >= 0 && deleteshm(sig2) >= 0)
printf(1, "[P] Share memory removed.\n");
else
{
printf(1, "[P] Share memory removing failed.\n");
exit();
}
printf(1, "Memory sharing test finished.\n");
printf(1, "================================\n");
return 0;
}