473,816 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Resizing shmop ?

Hi,

I need to resize the shmop but it seems that I can't seem to get it
right. Here's what I did

// initialize with 100 byte
$shm_id = shmop_open(0xff 3, "c", 0644, 100);
echo shmop_size($shm _id);
shmop_delete($s hm_id);
shmop_close($sh m_id);

// trying to resize to 200 byte but not working
$shm_id = shmop_open(0xff 3, "c", 0644, 200);
echo shmop_size($shm _id);
shmop_delete($s hm_id);
shmop_close($sh m_id);
However, if I try creating shmop with a large memory allocation, i can
open the shmop with smaller memory allocation. But it still does not
resize the allocation.

The delete doesn't seem to delete even though no resources are using
the shmop.

Thanks

Oct 30 '07 #1
1 3271
vmirage schrieb:
I need to resize the shmop but it seems that I can't seem to get it
right. Here's what I did
// initialize with 100 byte
$shm_id = shmop_open(0xff 3, "c", 0644, 100);
echo shmop_size($shm _id);
shmop_delete($s hm_id);
shmop_close($sh m_id);
// trying to resize to 200 byte but not working
$shm_id = shmop_open(0xff 3, "c", 0644, 200);
echo shmop_size($shm _id);
shmop_delete($s hm_id);
shmop_close($sh m_id);
However, if I try creating shmop with a large memory allocation, i can
open the shmop with smaller memory allocation. But it still does not
resize the allocation.
How do you make sure, that allocation doesn't work? Run the following
script as root using the command line interface. The memory usage is
displayed using the "ipcs -m" command.

<?php
// Create 100 byte shared memory block with system id of 0xff3
$shm_id = shmop_open(0xff 3, "c", 0644, 100);

if(!$shm_id) {
echo "Couldn't create shared memory segment\n";
}

// Get shared memory block's size
$shm_size = shmop_size($shm _id);
echo "SHM Block Size: " . $shm_size . " has been created.\n";

// Lets write a test string into shared memory
$shm_bytes_writ ten = shmop_write($sh m_id, str_repeat('x', 100), 0);
if ($shm_bytes_wri tten != 100) {
echo "Couldn't write the entire length of data\n";
}

// Show me what you got
echo shell_exec('ipc s -m');
// Recreate it with a larger size
$shm_id = shmop_open(0xff 3, "c", 0644, 200);

if (!$shm_id) {
echo "Couldn't create shared memory segment\n";
}

// Get shared memory block's size
$shm_size = shmop_size($shm _id);

echo "SHM Block Size: " . $shm_size . " has been created.\n";

// Lets write a test string into shared memory
$shm_bytes_writ ten = shmop_write($sh m_id, str_repeat('x', 200), 0);

if ($shm_bytes_wri tten != 200) {
echo "Couldn't write the entire length of data\n";
}

// Show me what you got
echo shell_exec('ipc s -m');

// Now lets read the string back
$my_string = shmop_read($shm _id, 0, $shm_size);

if (!$my_string) {
echo "Couldn't read from shared memory block\n";
}

echo "The data inside shared memory was: " . $my_string . "\n";

//Now lets delete the block and close the shared memory segment
if (!shmop_delete( $shm_id)) {
echo "Couldn't mark shared memory block for deletion.";
}

shmop_close($sh m_id);
?>

This should output:

SHM Block Size: 100 has been created.

------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000ff3 622592 root 644 100 1

The data inside shared memory was: xxx...
SHM Block Size: 200 has been created.

------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000ff3 655360 root 644 200 1

The data inside shared memory was: xxx...
Oct 30 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4025
by: Patricio Stegmann | last post by:
Hi, I am trying to develop a very basic but portable chat engine with php. I would like to develop it without any database or filesystem stuff, because I want it very portable and easy to install. So I was looking for a way to make scripts communicate, or keep a kind of state . So someone told me to look for shared memory operations... shmop_open and all this things.... but I cant seem to find a script that uses this, or something that...
10
2340
by: riki | last post by:
Hi, i have a big problem...i'm using one jscript for resizing of all of my pics in popUp...in main html i'm having many little pics and clicking on them they open in popUp and resize to larger version of the same pic. now, it works fine and sometimes when i click on little one it doesn't resize well... this is the code: main.html
0
2634
by: TJ Talluto | last post by:
<facts> I have a "month calendar" that always displays exactly 42 days... and alongside is a vertical box that displays the detail (form fields) of any particular select event that appears on the calendar, so that the event may be changed, or a new event may be created. monthname X X X X X X X form X X X X X X X form X X X X X X X form
5
4733
by: Jim | last post by:
I've heard that resizing images through PHP (either GD2 or ImageMagick) is a processor intensive exercise. I'm setting up a site where users will be uploading up to 10 images along with the details of their product. For each image uploaded (max 500Kb), I'll be resizing it to create a small, medium and large version after which I'll discard the original. My worry is that as the site becomes more popular, the processor time spent resizing...
12
6738
by: Søren Reinke | last post by:
Hi there I have a little problem. How do i make sure that a graph is not redrawn while the form with the graph is being resized ? I have tried to add a mouse up/down event handler on the form1, but it dosn't get called when resizing :( I would like to be able to resize my form, but also make sure the graph is
11
17887
by: Sharon | last post by:
I'm writing a new control derived from UserControl. I need to get an event when the control is done resizing. I tried the Resize, SizeChanged, Move and the Layout events and I also tried to override them. But they all invoked when the control is in the middle of the resizing process. I'm not using breakpoints, I'm using trace to see which one is invoked and when.
9
5317
by: dli07 | last post by:
Hello, I'm trying to convert a piece of code that creates a dynamic vertical resizing bar in a table from internet explorer to firefox. It's based on a post from http://blogs.crankygoblin.com/blogs/geoff.appleby/pages/50712.aspx. I've also read the post on this topic by bggraphics, but he doesn't arrive at a final result. The main problem I am having is that the layerX and layerY event properties don't work. They're supposed to return the...
10
7083
by: mishrarajesh44 | last post by:
hii all, I am facing a problem currently.. i have a script for image uploading and resizing.. the image uploading takes place properly for every size images.. but, the resizing works for only small sized iamages.. for eg. resizing takes place for 70 kb sized images but fails for 600kb or more.. my code is below..
1
2421
by: landacorp | last post by:
Hi, everyone! I am having trouble with values stored into the shared memory. Either i create "shmop_write" the value into the segment by cron and i being able to get it from the memory from command prompt ONLY with "/ usr/local/bin/php -q -f test.php", or i create the same way and the same segment (after freeing the momory) inside browser through apache and the value is available for command prompt and apache BOTH. The question is -...
0
9738
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9613
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10674
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10409
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10433
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7689
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6900
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5712
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3889
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.